Disabling Strict Standards in PHP 5.4

icomrade picture icomrade · Apr 2, 2012 · Viewed 148.9k times · Source

I'm currently running a site on php 5.4, prior to this I was running my site on 5.3.8. Unfortunately, php 5.4 combines E_ALL and E_STRICT, which means that my previous setting for error_reporting does not work now. My previous value was E_ALL & ~E_NOTICE & ~E_STRICT Should I just enable values one at a time?

I have far too many errors and the files contain too much code for me to fix.

Answer

David Stockton picture David Stockton · Apr 2, 2012

As the commenters have stated the best option is to fix the errors, but with limited time or knowledge, that's not always possible. In your php.ini change

error_reporting = E_ALL

to

error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT

If you don't have access to the php.ini, you can potentially put this in your .htaccess file:

php_value error_reporting 30711

This is the E_ALL value (32767) and the removing the E_STRICT (2048) and E_NOTICE (8) values.

If you don't have access to the .htaccess file or it's not enabled, you'll probably need to put this at the top of the PHP section of any script that gets loaded from a browser call:

error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);

One of those should help you be able to use the software. The notices and strict stuff are indicators of problems or potential problems though and you may find some of the code is not working correctly in PHP 5.4.