Disabling Strict Standards in PHP 5.4

前端 未结 5 1915
予麋鹿
予麋鹿 2020-11-28 04:18

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 m

相关标签:
5条回答
  • 2020-11-28 04:30

    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.

    0 讨论(0)
  • 2020-11-28 04:46

    If you would need to disable E_DEPRACATED also, use:

    php_value error_reporting 22527
    

    In my case CMS Made Simple was complaining "E_STRICT is enabled in the error_reporting" as well as "E_DEPRECATED is enabled". Adding that one line to .htaccess solved both misconfigurations.

    0 讨论(0)
  • 2020-11-28 04:51

    .htaccess php_value is working only if you use PHP Server API as module of Web server Apache. Use IfModule syntax:

    # PHP 5, Apache 1 and 2.
    <IfModule mod_php5.c>
        php_value error_reporting 30711
    </IfModule>
    

    If you use PHP Server API CGI/FastCGI use

    ini_set('error_reporting', 30711);
    

    or

    error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);
    

    in your PHP code, or PHP configuration files .user.ini | php.ini modification:

    error_reporting = E_ALL & ~E_STRICT & ~E_NOTICE
    

    on your virtual host, server level.

    0 讨论(0)
  • 2020-11-28 04:53

    It worked for me, when I set error_reporting in two places at same time

    somewhere in PHP code

    ini_set('error_reporting', 30711);
    


    and in .htaccess file

    php_value error_reporting 30711
    
    0 讨论(0)
  • 2020-11-28 04:54

    Heads up, you might need to restart LAMP, Apache or whatever your using to make this take affect. Racked our brains for a while on this one, seemed to make no affect until services were restarted, presumably because the website was caching.

    0 讨论(0)
提交回复
热议问题