how to check php syntax before execution

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • leegold2

    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.
  • Chris Hope

    #2
    Re: how to check php syntax before execution

    leegold2 wrote:
    [color=blue]
    > 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.[/color]

    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/

    Comment

    Working...