Search code examples
phperror-reporting

E_STRICT messages thrown though not set


Since updating my testing server to PHP 5.3.3 (Debian Squeeze) I encountered strange behaviour regarding the error reporting in PHP.

I set error_reporting like this:

error_reporting(E_ALL);

and checked the setting via

echo error_reporting();

which echoes 30719. According to php.net this means "All errors and warnings, as supported, except of level E_STRICT.".

But in the very next line (a class definition abstract class formInputContainer extends formContainer implements formElementValueable { ... }) this results in the message:

Strict (2048): Declaration of formInputContainer::addElement() should be compatible with that of formContainer::addElement()

Why is the E_STRICT message echoed though it's not set? Even changing to E_ALL & ~E_STRICT does not help.


Solution

  • If this is a custom error handler (set via set_error_handler()), you'll have to check the current error_reporting level by yourself. A custom error handler gets all error messages:

    The manual says:

    It is important to remember that the standard PHP error handler is completely bypassed for the error types specified by error_types unless the callback function returns FALSE. error_reporting() settings will have no effect and your error handler will be called regardless - however you are still able to read the current value of error_reporting and act appropriately.