If you're using php for web development, you may want to check syntax of your file without opening it on web browser.
PHP command-line interface (CLI) includes a nifty option to quickly check for any syntax errors in a source code file. A simple check for a single file is given below. The option flag to check is -l (lowercase ‘L’).
$ php -l example.php
If the file contains no syntax errors, the CLI returns the following message.
No syntax errors detected in example.php
If there is an error in the code the CLI will return the error depending on the context of the error.
Parse error: syntax error, unexpected '$var' (T_VARIABLE) in example.php on line:6
Errors parsing example.php
No comments:
Post a Comment