Disable strict standards in PHP 5.3.8 - php

I am using strict standards option in PHP but I want to disable it because Joomla doesn't like it and I have to use Joomla on my localhost.
In response to another question on this site, this solution was given: E_ALL & ~E_DEPRECATED & ~E_STRICT but this didn't work for me. I think it only works for PHP 5.4 while I am using 5.3.8.
Can anyone tell me what I should use? I am currently using error_reporting(E_ALL & ~E_NOTICE). Also I am using ini_set('display_errors') but there are still errors shown that are related to strict standards.
So how can I disable strict standard errors?

I have the same problem. This is how I fix it in joomla.
Set error_reporting in configuration.php of joomla to "30711" (equal to E_ALL & ~E_NOTICE & ~E_STRICT)

just messed around with this and would like to share my own results. I did not do it runtime using php, I did it in the php.ini file.
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT
Remeber to restart the server afterwards ....

I tried thanhtd's solution, but it didn't not work for me. However, I changed the error_reporting value to '1' instead of the default '0' in my configuration.php file for Joomla (2) and that worked. So thanks to thanhtd for getting me on the right path.

to suppress all errors use E_NONE
you might also want to use display_errors(0)

Related

if statement not working on new server, requires use of "empty"

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 disabled PHP Error reporting in php.ini but it continues to show in browser

So I have disabled PHP Errors inside my php.ini file (/etc/php5/apache2/php.ini) but they still continue to show in browser. I am running PHP version 5.5.9-1ubuntu4.13 and to do this I used the following:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE & ~E_WARNING
display_errors = Off
display_startup_errors = Off
Examples of errors still showing include:
Warning: Creating default object from empty value ...
and
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in ...
Any help/advice as to why these errors may still be showing would be greatly appreciated. Thanks!
So I finally figured this out, with the help of Ukavi in the comments.
The errors started to display after I had transferred the site from one server to another, and it appears that the first server ran an older version of PHP which is why they did not show up before.
Anyway, the fix. I added this to wp-config.php:
error_reporting(0);
ini_set('display_errors', 'off');
I also did a find in files for ini_set and found a few instances where they had been deliberately activated. As this site is not a solo project I wasn't aware of this!
Thank you for all the advice guys.

E_ALL & ~E_DEPRECATED not working as expected

Hi am working on a PHP site , it is an old system and i got an error
Deprecated: mysql_connect(): The mysql extension is deprecated and
will be removed in the future: use mysqli or PDO instead...
For now i am not going to change my queries to mysqli or PDO , i simply tried to add
error_reporting = E_ALL & ~E_DEPRECATED
to my php.ini and to remove the deprecated error messages . my php.ini is in C:/xampp/php/php.ini , after i added the value i restarted apache . also i tried with
error_reporting = E_ALL ^ E_DEPRECATED
also i tried with
error_reporting(E_ALL & ~E_DEPRECATED);
in my PHP , common header function , but the messages are showing . i want to remove them .
my MySQL version is 5.6.21
PHP version is 5.6.3
Thank you in advance .
Nothing present in your logs?
A quick browse around the net & SO seems to warrant trying this:
error_reporting(E_ALL ^ E_DEPRECATED);
Which should show all errors except for the deprecated warnings.
Your other option would be to specify only what you want to be displayed in your php.ini file.
error_reporting = |E_ERROR|E_WARNING|.....etc
References
error_reporting();
Predefined constants (flags)
And if the above doesn't work, this answer on ServerFault might clear things up (Providing different options for you to try.)
Maybe you see other error level message. Try:
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT);

Turn php error reporting off in xampp?

I just installed xampp, getting errors all over the place. Want to get rid of error handling. It's only annoying errors to do with my variables.
I'm not sure where to find php.ini, it doesn't exist in my C:\xampp\apache
Inside your php.ini make sure that you have display_errors to Off. From what I understand if you set display_errors to Off then the error_reporting directive doesn't need to change.
Example:
error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
display_errors = Off
in php.ini, do the following change,
display_errors = Off
This is very old now, but in case someone comes across this there's a XAMMP issue with version 5.6.3. I had the same issue with error display set to 'off' and it was still showing up as on in phpinfo()
For some reason, they added the error reporting in php.ini twice. display_errors shows on line 99 of php.ini, and then again on line 552.
So if you scroll down and disable the first one, the second one is still set to 'on' and overrides the first one leaving error reporting active.
I'm sure this will be fixed with future versions of XAMMP, but wanted to add this here for anyone that comes here looking for an answer to this problem.
If you set display_errors=off then all types of error will of.
But if you only want to notice error off the you can set
error_reporting = E_ALL & ~E_NOTICE
Xampp and other web applications have an error interface to show programmers (and users) execution errors or warnings (notices).
In order to modify the way Xampp shows errors you have to go control panel and open php.ini.
Inside this file you can find two points to modify the way it shows errors:
“display_errors = On”. From my point of view it has to be On all the time. If you put Off you won’t have any info regarding bad sentences.
“error_reporting=E_ALL”. This is the key point. Changing the value of it you can change the way it shows errors.
Inside php.ini is documented all options. My favorites:
error_reporting=E_ALL  it shows everything. Good for debug.
error_reporting=E_ALL & ~E_STRICT & ~E_DEPRECATED  it shows errors & notice (very important for debugging) and not shows suggestions & deprecated functions in next php versions.
error_reporting=E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED  production environment not including Notices.
I hope this fit for you.
More details https://community.apachefriends.org/f/viewtopic.php?f=17&t=50989

disabling deprecated errors

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.

Categories