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,374 times
2 Answers
1
http://fr2.php.net/php_check_syntax is your help. Check the examples !
![](../../users/profiles/15454.webp)
Dom
- 6,628
- 1
- 19
- 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
![](../../users/profiles/53998.webp)
The Shurrican
- 2,230
- 7
- 39
- 58
-
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