In PHP I am making a kind of bot which dynamically includes a few different PHP files. Since these PHP files may change, I would like the files to be checked for syntax/parse errors before the include() or require() is run. Would this be possible? If so, how?
Asked
Active
Viewed 1,401 times
2 Answers
1
http://fr2.php.net/php_check_syntax is your help. Check the examples !

Dom
- 6,743
- 1
- 20
- 24
-
1Note: For technical reasons, this function is deprecated and removed from PHP. Instead, use php -l somefile.php from the commandline. – The Shurrican May 26 '12 at 19:48
0
use the php executeable with the -l argument from the command line. you can do that using a system call, or shell_exec

The Shurrican
- 2,240
- 7
- 39
- 60
-
Thanks. I am assuming that there is no more efficient way of achieving this, since I've noticed that the exec("php -l {$file}"); pauses the script for a second. – Dead-i Jun 04 '12 at 06:31