PHP not displaying errors even though display_errors = On

前端 未结 17 1612
面向向阳花
面向向阳花 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:18

    Although this is old post... i had similar situation that gave me headache. Finally, i figured that i was including sub pages in index.php with "@include ..." "@" hides all errors even if display_errors is ON

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

    For me I solved it by deleting the file of php_errors.txt in the relative folder. Then the file is created automatically again when the code runs next time, and with the errors printed this time.

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

    I had the same problem on my virtual server with Parallels Plesk Panel 10.4.4. The solution was (thanks to Zappa for the idea) setting error_reporting value to 32767 instead of E_ALL. In Plesk: Home > Subscriptions > (Select domain) > Customize > PHP Settings > error_reporting - Enter custom value - 32767

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

    Just want to add another pitfall here in case someone finds this question with a problem similar to mine.

    When you are using Chrome (Or Chromium) and PHP triggers an error in PHP code which is located inside of a HTML attribute then Chrome removes the whole HTML element so you can't see the PHP error in your browser.

    Here is an example:

    <p>
      <a href="<?=missingFunc()?>">test</a>
    </p>
    

    When calling this code in Chrome you only get a HTML document with the starting <p> tag. The rest is missing. No error message and no other HTML code after this <p>. This is not a PHP issue. When you open this page in Firefox then you can see the error message (When viewing the HTML code). So this is a Chrome issue.

    Don't know if there is a workaround somewhere. When this happens to you then you have to test the page in Firefox or check the Apache error log.

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

    I had the same issue and finally solved it. My mistake was that I tried to change /etc/php5/cli/php.ini, but then I found another php.ini here: /etc/php5/apache2/php.ini, changed display_errors = On, restarted the web-server and it worked!

    May be it would be helpful for someone absent-minded like me.

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

    When you update the configuration in the php.ini file, you might have to restart apache. Try running apachectl restart or apache2ctl restart, or something like that.

    Also, in you ini file, make sure you have display_errors = on, but only in a development environment, never in a production machine.

    Also, the strictest error reporting is exactly what you have cited, E_ALL | E_STRICT. You can find more information on error levels at the php docs.

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