PHP not displaying errors even though display_errors = On

前端 未结 17 1610
面向向阳花
面向向阳花 2020-12-13 01:31

I have a Ubuntu server running Apache2 with PHP 5. In the php.ini I set display_errors = On and error_reporting = E_ALL | E_STRICT, but PHP is st

相关标签:
17条回答
  • 2020-12-13 02:09

    I know this thread is old but I just solved a similar problem with my Ubuntu server and thought I would add a note here to help others as this thread was first page in Google for the topic of PHP not displaying errors.

    I tried several configuration settings for the error_reporting value in php.ini. From E_ALL | E_STRICT to E_ALL & E_NOTICE and none worked. I was not getting any syntax errors displayed in the browser (which is rather annoying on a development server). After changing the error_reporting setting to "E_ALL" it all started working. Not sure if it is an Ubuntu Oneric specific issue but after restarting Apache errors started showing in the HTML pages the server was serving. Seems the extra options confusing things and all error reporting stops. HTH somone else.

    0 讨论(0)
  • 2020-12-13 02:12

    When running PHP on windows with ISS there are some configuration settings in ISS that need to be set to prevent generic default pages from being shown.

    1) Double click on FastCGISettings, click on PHP then Edit. Set StandardErrorMode to ReturnStdErrLn500.

    StandardErrorMode

    2) Go the the site, double click on the Error Pages, click on the 500 status, click Edit Feature Settings, Change Error Responses to Detailed Errors, click ok

    Change Error Responses to Detailed Errors

    0 讨论(0)
  • 2020-12-13 02:15

    You also need to make sure you have your php.ini file include the following set or errors will go only to the log that is set by default or specified in the virtual host's configuration.

    display_errors = On
    

    The php.ini file is where base settings for all PHP on your server, however these can easily be overridden and altered any place in the PHP code and effect everything following that change. A good check is to add the display_errors directive to your php.ini file. If you don't see an error, but one is being logged, insert this at the top of the file causing the error:

    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    

    If this works then something earlier in your code is disabling error display.

    0 讨论(0)
  • 2020-12-13 02:16

    I had the same problem but I used ini_set('display_errors', '1'); inside the faulty script itself so it never fires on fatal / syntax errors. Finally I solved it by adding this to my .htaccess:

    php_value auto_prepend_file /usr/www/{YOUR_PATH}/display_errors.php
    

    display_errors.php:

    <?php
    ini_set('display_errors', 1);
    error_reporting(-1);
    ?>
    

    By that I was not forced to change the php.ini, use it for specific subfolders and could easily disable it again.

    0 讨论(0)
  • 2020-12-13 02:17

    I had the same problem with Apache and PHP 5.5. In php.ini, I had the following lines:

    error_reporting E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT
    display_errors Off
    

    instead of the following:

    error_reporting=E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT
    display_errors=Off
    

    (the =sign was missing)

    0 讨论(0)
  • 2020-12-13 02:17

    I also face the same issue, I have the following settings in my php.inni file

    display_errors = On
    error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT
    

    But still, PHP errors are not displaying on the webpage. I just restart my apache server and this problem was fixed.

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