Since php 8 I'm having an issue with handling what logs should save to logs.
By setting the E_ALL & ~E_WARNING & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED value on php 7 as error_reporting, the warnings are excluded from the log.
By setting the same value in a domain with PHP 8 the warnings are still saved inside the log file, even by changing the value of error_reporting in the php.ini file.
In PHP 8 i have try without success:
E_ALL & ~E_WARNING & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
E_ALL & ~E_WARNING & ~E_NOTICE & ~E_CORE_WARNING & ~E_COMPILE_WARNING & ~E_USER_WARNING & ~E_USER_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_USER_DEPRECATED
I tried restarting all the services but the warnings keep getting saved in the logs for the php8, does anyone have any solution?
Related
I've inherited some code that is working great on one server, which is running PHP 7.1.7. Throughout the code their are numerous if statements similar to the following that are checking to see if a variable exists.
if ($_SESSION['user'])
if ($_POST['company_id'])
On the new server, which as PHP 7.2.5, these if statements are throwing errors. I'm having to change them all to use "empty".
if (empty($_SESSION['user']))
if (!empty($_POST['company_id']))
This wouldn't be a big deal if there were only a few, but there's 100+. I've tried changing the PHP version to 7.1.7 on the new server to match the old, but still have the same issue.
I have to imagine there is a setting somewhere that could be changed to allow these work without the need to use "empty" on all of them. Thanks for any insight.
Like #IncredibleHat suggested, you can prevent this by suppressing error notices. Any one of these three should address the warnings.
// this can go in your PHP
ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
// OR you can put this in your .htaccess file
php_value error_reporting E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
// OR you can put this in your php.ini file
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
I have WAMP with php 5.4.12 and I want to report errors.
My php.ini contains the following:
; Common Values:
; E_ALL & ~E_NOTICE (Show all errors, except for notices and coding standards warnings.)
; E_ALL & ~E_NOTICE | E_STRICT (Show all errors, except for notices)
; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors)
; E_ALL | E_STRICT (Show all errors, warnings and notices including coding standards.)
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; http://php.net/error-reporting
error_reporting = E_ALL
but no errors are showing.
What value should error_reporting take and how can I retrieve the reported errors?
I guess display_errors is turned off in your php.ini. Try the following instead (in the php file you are working on).
ini_set('display_errors' , 'On');
error_reporting(E_ALL);
For setting the flag on from php.ini, locate where display_errors is and change the value to On. Post your full php.ini if this does not work.
Can you check whether any error reporting flag in the php script(which will overwrite the php ini flags) in which you are trying to run and also in the .htaccess file. These are the two options which overwrites the php .ini flags.
So, I am just about ready to kill a kitten. This is driving me up the wall.
I have a php file I need to include, call it functions.php I have tried the following to include it:-
include './includes/functions.php';
When I did this, I discovered that I get a White Screen of Death. So I went onto more creative solutions;
echo ((include $_SERVER['DOCUMENT_ROOT']. "/includes/functions.php") == 'OK') ? 'GOOD IMPORT' : 'BAD IMPORT';
This was purely to see a visual response to the import. But to no avail, still the White Screen of Emptiness.
The file does exist.
Please, any help is greatly appreciated.
Seems like /includes/functions.php has a syntax error, To stop the "White screen of Death" edit your php.ini
; display_errors
; Default Value: On
; Development Value: On
; Production Value: Off
; display_startup_errors
; Default Value: Off
; Development Value: On
; Production Value: Off
; error_reporting
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
are values you should probably use. Thats from a stock php.ini file
I am trying to disable Strict Standards from showing up on my screen.
I took a look at my php.ini files and see these lines:
; error_reporting
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
What do these lines mean and how do I disable the Strict Standards error from showing up?
I also see this line
error_reporting = E_ALL | E_STRICT
I'd change this line
error_reporting = E_ALL | E_STRICT
to the production Production Value
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
You can also change the display_errors settings which will allow you to log errors, but not display them
display_errors = Off
I recently migrated to PHP 5.3.2, and realized that I am unable to turn off notice errors in my site now. I went to php.ini, and in these lines:
; Common Values:
; E_ALL & ~E_NOTICE (Show all errors, except for notices and coding standards warnings.)
; E_ALL & ~E_NOTICE | E_STRICT (Show all errors, except for notices)
; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors)
; E_ALL | E_STRICT (Show all errors, warnings and notices including coding standards.)
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; http://php.net/error-reporting
error_reporting = E_ALL & ~E_NOTICE
...I've tried setting everything (and I restart apache each time), but I am unable to get rid of notices.
The only way I'm able to get rid of notice errors is by setting :
display_errors = Off
That is, of course, not something I can do since I need to see errors to fix them, and I would like to see errors on the webpage that I am coding rather than log them somewhere.
Can someone help? Is this a bug in PHP 5.3.2 or something I am doing wrong?
Thank you very much for your time!
P. S. Also, would anyone know how I can get PHP 5.3.2 to support the .php3 extension?
Okay, I figured what was going wrong. I set error_reporting in my code, which was overwriting the php.ini error_reporting.
Now the reason that that same stuff was working until I upgraded to PHP 5.3.2 was this - in my code, I set the error_reporting command:
error_reporting(6143);
I should've set it as:
error_reporting(E_ALL ^ E_NOTICE);
I'm guessing the meaning of 6143 is different in PHP 5.3.2 compared to in 4.1 (or whatever my earlier version was).
As for the php3 extension, it was to be set in the /etc/httpd/conf.d/php.conf file:
AddHandler php5-script .php .php3
AddType text/html .php
Thank you, sourcez, for your suggestions!
I too faced same error today in my website where i use TCPDF Library to generate PDFs. It was working fine but suddenly i started to get the following error today
Severity: 8192
Message: Imagick::clone method is deprecated .....
Might be the hosting provider updated PHP or Imagick. PHP - 5.4 and Imagick - 3.x
So to get rid of this in my code, i set error_reporting as
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
And this will show the errors but not the deprecated notices. Meanwhile I can change my code to support the new version of Imagick.