I'm using the built in PHP server and I'd like to suppress the strict warnings. In my php.ini file i have:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
...but it is still printing strict and deprecated notices. I verified that I was editing the correct ini file by checking a page with phpinfo().
In the built in webserver documentation, there is no mention of special error reporting rules.
I have also tried this:
error_reporting(E_ALL ^ E_STRICT ^ E_DEPRECATED);
ini_set("display_errors", "off");
print "changed stuff";
"changed stuff" is printed, along with strict and deprecated notices.
What do I need to do to suppress these errors in the PHP built in webserver? (Can this be done?)
Try changing like this [Reports all errors except STRICT ]
Through Code
<?php
error_reporting(E_ALL ^ E_STRICT);
Through PHP.ini
error_reporting = E_ALL ^ E_STRICT
I searched through my code (it's a very old codebase) and found several instances where the error reporting was manually set. Once i removed those it worked.
Check your files for error_reporting calls
Related
In my web app my boss wants me to use msql_* php functions but I can't even login because of PHP messages about these deprecated functions. How can I disable them in MAMP? Looking in this forum I've found the following rules to write inside php.ini
error_reporting = E_ALL & ~E_DEPRECATED
display_errors = On
disable_functions = "list of mysqli_* functions"
but this doesn't work. I've written this to all file php.ini of each php version contained in MAMP. The only thing that works is to put
display_errors = Off
but I can't use it like that otherwisw I won't even be able to see my programming/syntax error of other problems.
Here is my php.ini of php 5.6.10 inside /Applications/MAMP/bin/php/php5.6.10/conf/
Do you have any ideas? I know I should use new functions and not deprecated ones but it's not up to me and I can't disable all error messages...
I don't really have a solution for you, I'm sorry.
I did like that : in my .php files I put this code :
error_reporting(E_ALL ^ E_DEPRECATED); // without "~"
ini_set("display_errors", 1);
It seems to work.
Within the TEMATRES program (which is the program I use) there is a configuration file: config.tematres.php. This file has the following line:
Ini_set ('display_errors', 'On');
Error_reporting (E_ALL);
I changed it to:
Ini_set ('display_errors', 'On');
Error_reporting (E_ALL ^ E_DEPRECATED);
And thus I was able to solve the problem.
I'm having trouble turning off deprecated warnings for a short period of time. They're coming from a junk-pile script that I'm forced to work on for a while, wherein they use preg_replace with the /e modifier excessively. Rather than go and fix all the places that do this, it seemed like a better idea to turn off deprecated warnings while I'm working on it.
The problem, oddly enough, is that the error_reporting function at the beginning said script seems to have only an "On/Off" effect. That is, I can turn reporting fully off with error_reporting(0), and I can have it all on with something like error_reporting(E_ALL). But using any of the following options has no affect. I still get some 100+ deprecated warnings at the top of my page.
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
error_reporting(E_ALL & ~E_DEPRECATED);
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
I've verified that my php.ini file is set to E_ALL & ~E_DEPRECATED) (24575), and it shows as such in phpinfo(). The .htaccess file in the project root is empty. Why there even is one, I don't know.
PHP 5.5.9-1ubuntu4.4
Any ideas?
I would say there is probably another page or script that is being included that is setting error_reporting to a different value. You can call error_reporting() with no args to get the current value. Set it to something and check that the value hasn't changed after including other files.
error_reporting(E_ALL | E_STRICT);
just says "hey, log these kinds of errors/warning/notice"
I think you will need -
ini_set('display_errors', '0');
Try it out.
Solution :
ini_set("display_errors",'off');
Use this in your php script.It will hide warnings coming in your page.
Other interesting options for that function:
<?php
// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);
// For PHP >=5.3 use: E_ALL & ~E_NOTICE
// Report all PHP errors (see changelog)
error_reporting(E_ALL);
// Report all PHP errors
error_reporting(-1);
// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
?>
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:
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();
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
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.
Set your error report to
error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
on your php page.
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.
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.
I have a script that need Strict Standards Off ~E_STRICT, but I cant understand how can I off strict standards on PHP. I have centos 6.4 with WHM installed VPS
If you want to repport all errors but stric, use error_reporting(E_ALL ^ E_STRICT);. If you want to repport all errors, use error_reporting(E_ALL); if you want to log all errors but not show them, use ini_set('display_errors', '0'); error_reporting(E_ALL); or change the display_errors directive in the php.ini manually and set it to off.
I want to enable deprecated errors globally but disable them for a specific piece of third-party code, which I don't have the time to fix.
So, I have this in php.ini:
error_reporting = E_ALL & ~E_NOTICE | E_DEPRECATED
and this right before the line where I want to disable the warnings
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
However, it does not work, I'm still getting the warnings for that particular line. If I disable them globally in php.ini it works. I'm using PHP 5.3.10. Any ideas what might be wrong?
Figured it out. The third party code has custom error handler and apparently it's overriding anything you set with error_reporting(). When I commented out the set_error_handler() line, error_reporting() took effect.
Add the below error reporting line in your php.ini:
error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE & ~E_DEPRECATED);
Then restart your server and check it.