Page 1 of 1

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

Posted: Wed May 14, 2008 12:10 am
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.

Re: find parse errors in php file without executing it

Posted: Wed May 14, 2008 12:16 am
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.