
How To Check Php Syntax Using The Command Line
1
Open Terminal or any other unix shell
If you’re on a Mac you can open Terminal which is located in:
Applications/Utilities2
Navigate to your project folder
You can navigate to your project folder by using the change directory or cd command followed by the directory. For me it is: cd /Users/josephtylerjones/Developer/scripts/
3
Use the php command with the -l option
Now you can check the syntax of your script by running php -l followed by the file name. For me it is:
php -l testfile.phpThis command will detect any syntax errors in your script!