3

During development, I use

error_reporting(E_ALL | E_STRICT | E_NOTICE);

Sometimes, though rarely, there are specific E_STRICT errors I'd like to ignore. But I don't want to turn off E_STRICT entirely.

Is there a way to ignore specific errors, whether via error code, or even, as hacky as it is, via string-comparing the error message itself?

Thanks in advance.

4
  • before problematic code again add error_reporting(E_ALL | E_NOTICE); -- or use @ before function
    – user956584
    Commented Aug 5, 2012 at 8:51
  • Hm, how would I do this if the error is being raised by a class definition? For example, the specific error I want to ignore is: Strict Standards: Declaration of foo::test() should be compatible with that of bar::test(). (I am extending a class but purposefully wish for a derived method to take more parameters than the overridden method.) Commented Aug 5, 2012 at 8:56
  • 3
  • That would indicate to me that you have some issues in your application architecture. PHP is trying to warn you of this, you shouldn't ignore those warnings.
    – vascowhite
    Commented Aug 5, 2012 at 9:28

2 Answers 2

4

Ofcourse you can, look at set_error_handler, you pass name of your function, which will be called, when some error happen. There you can ignore errors, do what you want, or just send them to normal PHP error output.

-1

When you like to ignore specific error types then use the following format

error_reporting( E_ALL ^ E_NOTICE )

More information you'll find under http://www.php.net/manual/en/function.error-reporting.php

1
  • as everybody knows there are more then the given options. therefor my advice wasn't that bad. follow the link!
    – devanand
    Commented Dec 19, 2013 at 10:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.