I want to supress warning from this trigger_error('Deprecated', E_USER_DEPRECATED);
in runtime. From I have read I can use error_reporting(E_ALL & -E_USER_DEPRECATED & -E_DEPRECATED);
. But that does not work. I tried if error_reporting
works in general by using error_reporting(0)
. This works. What did I miss? I did not find another way to solve my problem. And did not notice that this way does not work for someone else.
My code which does not suppress deprecated warning:
error_reporting(E_ALL & -E_USER_DEPRECATED);
trigger_error('Deprecated', E_USER_DEPRECATED);
Php version: 7.0.14
.
You have a syntax error in the value for error_reporting(). To exclude certain errors you need to use the tilde symbol ~
instead of the dash -
:
error_reporting(E_ALL & ~E_USER_DEPRECATED);
// ^ this one
trigger_error('Deprecated', E_USER_DEPRECATED);