find parse errors in php file without executing it [SOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

find parse errors in php file without executing it [SOLVED]

Post by s.dot »

http://shiflett.org/blog/2007/dec/php-advent-calendar-day-17 wrote:

Code: Select all

find /path/to/code -name \*.php | xargs -n1 php -l
This command searches through the /path/to/code directory for all files with a .php extension (adjust as necessary to match your own naming conventions; add another extension such as .inc by appending -o -name \*.inc to the find command) and passes them one at a time to PHP's CLI binary with -l to indicate lint mode. In this mode, the file is parsed but not executed, and any existing parse errors will be identified. The scripts stops execution if a parse error is encountered.
How can I do this on windows? I do have php accessible from the command line.

EDIT| I just want to do one file, not a directory.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: find parse errors in php file without executing it

Post by s.dot »

Alrighty, nevermind. I was looking at the deprecated function php_check_syntax() and found the user comments helpful.

Code: Select all

C:\Users\Scott>php -l c:\apache2\htdocs\bs\includes\php\cron\cron_hour.php
No syntax errors detected in c:\apache2\htdocs\bs\includes\php\cron\cron_hour.php
 
C:\Users\Scott>
I wonder why php_check_syntax() was removed.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply