My server is running PHP 5.3 and my WordPress install is spitting these errors out on me, causing my session_start() to break.
Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 647
Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 662
Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 669
Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 676
Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 712
This is annoying, but I do not want to turn off on screen error reporting. How do I disable these bothersome deprecated warnings?
I am running WordPress 2.9.2.
You can do it in code by calling the following functions.
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
or
error_reporting(E_ALL ^ E_DEPRECATED);
To only get those errors that cause the application to stop working, use:
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING | E_DEPRECATED));
This will stop showing notices, warnings, and deprecated errors.
I needed to adapt this to
error_reporting = E_ALL & ~E_DEPRECATED
You have to edit the PHP configuration file. Find the line
error_reporting = E_ALL
and replace it with:
error_reporting = E_ALL ^ E_DEPRECATED
If you don't have access to the configuration file you can add this line to the PHP WordPress file (maybe headers.php):
error_reporting(E_ALL ^ E_DEPRECATED);
I just faced a similar problem where a SEO plugin issued a big number of warnings making my blog disk use exceed the plan limit.
I found out that you must include the error_reporting command after the wp-settings.php require in the wp-config.php file:
require_once( ABSPATH .'wp-settings.php' );
error_reporting( E_ALL ^ ( E_NOTICE | E_WARNING | E_DEPRECATED ) );
by doing this no more warnings, notices nor deprecated lines are appended to your error log file!
Tested on WordPress 3.8 but I guess it works for every installation.
All the previous answers are correct. Since no one have hinted out how to turn off all errors in PHP, I would like to mention it here:
error_reporting(0); // Turn off warning, deprecated,
// notice everything except error
Somebody might find it useful...
In file wp-config.php you can find constant WP_DEBUG. Make sure it is set to false.
define('WP_DEBUG', false);
This is for WordPress 3.x.
I tend to use this method
$errorlevel=error_reporting();
$errorlevel=error_reporting($errorlevel & ~E_DEPRECATED);
In this way I do not turn off accidentally something I need
If PHP warnings are breaking things in WordPress, but you still want to know what the warnings are, you can disable displaying PHP errors/warnings and only send them to the log file:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', true );
this error occur when you change your php version: it's very simple to suppress this error message
To suppress the DEPRECATED Error message, just add below code into your index.php file:
init_set('display_errors',False);
Related
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);
I'm have a problem supressing php warnings - they keep showing up on my php pages. For example, this one:
Strict Standards: Non-static method MyTimer::instance() should not be called statically in C:\eclipse-php\workspace\web\mypackage\classes\Timer.class.php on line 270
I'm using xampp, and modified php.ini to include this directive:
error_reporting = E_ALL & ~E_STRICT
and restart apache, but it makes no differences.
Any suggestions?
In my opinion, you should correct the error, but you can disable the error message also quite simple:
ini_set('display_errors', '0'); # don't show any errors...
error_reporting(E_ALL | E_STRICT); # ...but do log them in apache log
set this code in your *.php file for example "index.php"
more information:
http://php.net/manual/en/function.error-reporting.php
I hope it works fine for you
Grezz Dave
I was getting this error since I was using a third party application using mysql_ prefix.
Deprecated: The mysql extension is deprecated and will be removed in
the future: use mysqli or PDO instead in /path/to/filename.php on line
123
So i tried to hide this error by editing my php.ini file. I have tried adding
error_reporting = E_ALL ^ E_DEPRECATED;
But that didn't work.
So I tried this
error_reporting(E_ALL ^ E_DEPRECATED);
That too didn't work. What may be the issue? Is it with my php.ini file, or am I doing it wrong. Please let me know the correct method to hide this deprecated error message (or what was wrong with the methods i used).
You need to logically AND the negated E_DEPRECATED flag in order to disable it:
error_reporting(E_ALL &~ E_DEPRECATED);
Try this to deprecate error messages of 3rd third party tools.
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);
when a query doesn’t match e.g user name and password, the localhost returns an warning message. how can i turn it off?
i think there is some
Can someone guide me please?
waning message is this
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 2 in /var/www/login/loginform.php on line 24
Edit your PHP.ini file :
Set these two lines as :
display_errors = Off
display_startup_errors = Off
You really should fix whatever's causing the warning, but you can hide / show errors with error_reporting. To hide warning messages, you could use something like this:
error_reporting(E_ERROR | E_PARSE);
You must fix your code rather turning it off.
If you want to off warnings you can set it in php.ini of your server. Set
error_reporting = E_ALL & ~E_NOTICE
I recommend doing this globally is not a good idea. So do it in your project using PHP. To do this you can use PHP function
error_reporting(E_ALL ^ E_NOTICE);
Put this function before where your code starts execution.
I've set my error_reporting to
error_reporting = E_ALL & ~E_DEPRECATED ^ E_STRICT
in php.ini. The numerical value according to phpinfo() is 22527.
However we are still logging plenty of
[01-Oct-2011 13:06:36] PHP Deprecated: Assigning the return value of new by reference is deprecated in /htdocs/www/site/core.php on line 2381
[01-Oct-2011 13:06:36] PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /htdocs/www/site/core.php on line 1538
I've seen a few other questions about this, but not with any solutions I haven't tried. We're using (an outdated version of) VBulletin. Could that be changing the setting?
I see now that VBulletin's forumdisplay.php has a line
error_reporting(E_ALL & ~E_NOTICE);
Commenting this out didn't change anything.