470,866 Members | 1,878 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,866 developers. It's quick & easy.

how to check php syntax before execution

Newbie question:

In Perl I could do #perl -c myscript.pl and with that "-c" it won't run,
but will just "compile" it, so I get all my syntax errors. Is there a
similar
thing in PHP? A way to catch my syntax errors before I actually run my
program.

Thanks,
Lee G.
Jul 17 '05 #1
1 1999
leegold2 wrote:
In Perl I could do #perl -c myscript.pl and with that "-c" it won't
run, but will just "compile" it, so I get all my syntax errors. Is there a
similar
thing in PHP? A way to catch my syntax errors before I actually run my
program.


Assuming you have the command line version of PHP as well as the web server
module, you can run
php -l filename.php

to run a syntax check. It doesn't execute the file, just checks it, and if
everything worked out ok you get the following message:
No syntax errors detected in filename.php

--
Chris Hope
The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Francesc Guim Bernat | last post: by
1 post views Thread by Francesc Guim Bernat | last post: by
34 posts views Thread by Chris | last post: by
127 posts views Thread by bz800k | last post: by
4 posts views Thread by FM | last post: by
15 posts views Thread by puzzlecracker | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.