Background info:
If your error_reporting
settings are being setup via function call (not settings files), a syntax error which occurs in the first file being loaded (ex.: index.php
) the PHP interpreter can't output the error.
If you have a very simple index.php
file which includes the file with the fatal syntax error in it, then the PHP interpreter will be able to output the error.
This is a "known limitation" of the PHP interpreter caused by the fact that most interpreters need to read the file in two passes first to pick up the tokens and then to assess if the tokens correctly represent the language's grammar (allowed order of tokens).
Actually running the code happens after the interpreter finishes these two passes successfully; if it doesn't then all the information the interpreter has is that a syntax error occurred, it doesn't know that you have set error_reporting
to some level or another because it considers whatever it read from the file to be "invalid syntax" so it can't run it.
Concrete info:
Since you're using a new syntactic language construct that PHP 5.4 provides but PHP 5.3 doesn't, the legitimate PHP 5.4 construct becomes a syntax error in PHP 5.3.
Having a call to error_reporting
in the same file as the syntax error means the function call will not occur and the error level will not be correctly set.
Workaround:
Set your error level by declaring it in your php.ini
file or .htaccess
file.