Connecting Tech Pros Worldwide Forums | Help | Site Map

what is the best way to test for parse errors?

lkrubner@geocities.com
Guest
 
Posts: n/a
#1: Jul 17 '05

I'm thinking I'll write a script that loops through all the PHP files
in a folder and does two tests, first to see if a file is there and
then to see if it can be included(). If file_exists() is true and
included() is false, there is probably a parse error in that file. I'll
then have the script spit out a warning for me.

Does anyone have a better idea than this?

NC
Guest
 
Posts: n/a
#2: Jul 17 '05

re: what is the best way to test for parse errors?


lkrubner@geocities.com wrote:[color=blue]
>
> I'm thinking I'll write a script that loops through all the PHP files
> in a folder and does two tests, first to see if a file is there and
> then to see if it can be included(). If file_exists() is true and
> included() is false, there is probably a parse error in that file.
> I'll then have the script spit out a warning for me.[/color]

Inclusion can produce variable name collisions...
[color=blue]
> Does anyone have a better idea than this?[/color]

You can call the command-line interpreter with the -l key. This
option tells the interpreter not to execute the script, but only
to check its syntax.

If the script is not found, the interpreter will return:

Could not open input file: script.php.

If the script is found and syntax check is sucessful, the
interpreter will return:

No syntax errors detected in scrip.php

If the interpreter's response is something other than those
two, there's a syntax error.

Cheers,
NC

Closed Thread