2

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.

1
  • I think what you want is a tilde, try error_reporting(E_ALL & ~E_DEPRECATED); Commented Mar 12, 2018 at 14:16

1 Answer 1

9

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.