23

I am working on project @ home and using WAMP for development. Currently the php.ini file has the following lines set like this:

error_reporting = E_ALL & ~E_DEPRECATED
display_errors = On

I had hoped in doing so it would prevent deprecation warnings from showing up. However it is not. Is there a way I can adjust error_reporting to ignore deprecated warnings.

Output I am getting currently:

Screen of the problem

5

6 Answers 6

35

You can use this function :

error_reporting(E_ALL ^ E_DEPRECATED);

http://www.php.net/manual/en/function.error-reporting.php

Or use "@" operator before function name.

@mysql_connect();
1
  • 3
    Thanks, Using PHP 5.5.9 on Ubuntu error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT Have no effect.... but "@mysql_connect();" do the trick
    – molokoloco
    Feb 4, 2016 at 14:38
20

In your php.ini file change the following.. (note wamp has 2 different php.ini files so make the changes on both)

from this

error_reporting = E_ALL

to this

error_reporting = E_ALL & ~E_DEPRECATED
6

I had the same problem. It turned out however, that I edited wrong php.ini file. In my case the correct one was

C:\wamp64\bin\php\php5.6.25\phpForApache.ini

and in this file I have changed this line to:

error_reporting = E_ALL & ~E_DEPRECATED.

It didn't make any difference what I had changed in that "obvious" php.ini file.

3

Set your error report to

error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

on your php page.

2

If you want to show all errors except deprecated, then use this setting:

error_reporting = E_ALL ^ E_DEPRECATED

Edit: You could also create a custom error handler to hide only mysql_ deprecation warnings:

set_error_handler(function($errno, $errstr) {
    return strpos($errstr, 'mysql_') === 0;
}, E_DEPRECATED);

But please note that mysql_ functions are deprecated. So instead of trying to hide the errors, consider switching to mysqli or PDO.

2
  • Did you restart the server? Jul 3, 2014 at 17:39
  • Yes I did. But it is not working error_reporting = E_ALL & ~E_DEPRECATED is now in php.ini Jul 3, 2014 at 17:45
2

To hide php errors on WAMP server, Please open php.ini file and find following line of code

error_reporting = E_ALL

and replace it with

error_reporting = E_ALL & ~E_NOTICE

All errors will be hide/disable.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

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