How to check PHP syntax using the command line

Tyler Tyler (304)
1 minute

If you're using PHP for web development, you may often want to check the syntax of your file without opening it in a browser. Checking syntax is quite easy from the command line.

Visit this guide to learn how to check your PHP version.


Howchoo is reader-supported. When you buy through links on our site, we may earn a small affiliate commission at no cost to you.

If you're on a Mac you can open Terminal which is located in:


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/

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.php
This command will detect any syntax errors in your script!

Tyler Tyler (304)
5 minutes

Continuous integration is pretty trendy, but despite that fact, it's also pretty useful. This guide will show you how to set up your first project in CircleCI.