PHP allows you to check your script syntax without running the code. Just use the – l switch with php command. It will check the syntax error in your script and show the “Unexpected token …” error message if there is any syntax error in your script.
Here First we will create a php file “Hello.php”
Command to check syntax errors in your PHP script:
Below is the screen that showing running php command with error messages.