Differences
This shows you the differences between two versions of the page.
litespeed_wiki:php:why-php-error-reporting-not-working [2019/07/26 20:56] Jackson Zhang created |
litespeed_wiki:php:why-php-error-reporting-not-working [2019/07/29 16:25] (current) Lisa Clarke Proofreading |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Why PHP error reporting not working? ====== | + | ====== Troubleshooting PHP Not Reporting Errors ====== |
- | A user tries to enable PHP error reporting for PHP code troubleshooting. From the phpinfo.php page, seems the local values are correct. | + | You've enabled PHP error reporting so that you may troubleshoot PHP code, but for some reason, no errors are being reported. Why? |
+ | |||
+ | On the ''phpinfo.php'' page, you see the following local values, which are correct: | ||
display_errors On | display_errors On | ||
display_startup_errors On | display_startup_errors On | ||
Line 7: | Line 9: | ||
error_reporting E_ALL | error_reporting E_ALL | ||
- | Create a test script test.php like the following: | + | To diagnose the issue, let's create a test script called ''test.php'' and add the following lines: |
<?php | <?php | ||
Line 13: | Line 15: | ||
?> | ?> | ||
| | ||
- | Since the faked function ''zzzzzxzzzzxd'' doesn't exit at all, it should trigger a fatal error when visiting http://youdomain.com/testing.php. However, there is no outputting any error on web browser, neither on the local VirtualHost PHP error logs. | + | Since the faked function ''zzzzzxzzzzxd'' doesn't exit at all, visiting ''<nowiki>http://youdomain.com/test.php</nowiki>'' should trigger a fatal error. However, there is no output of any error on the web browser, nor on the local VirtualHost PHP error logs. Why not? |
- | + | ||
- | What could be possibly wrong? | + | |
- | After checking the phpinfo page, we can see error_log global value showing as ''32767'' and local value showing as ''E_ALL''. Further check the global php.ini, ''error_reporting = E_ALL''. User has a local override in .htaccess as ''php_value error_reporting E_ALL''. | + | Check ''phpinfo.php'' again. We see **error_log**'s global value is ''32767'', while the local value is ''E_ALL''. Check the global ''php.ini'' and you will find that **error_reporting** is set to ''E_ALL''. This is because you have a local override set in .htaccess as ''php_value error_reporting E_ALL''. |
- | The error reporting syntax in .htaccess php_value override is incorrect. If it is set in php.ini, it should be ''error_reporting = E_ALL'', but if it is override in apache conf or .htaccess, ''error_reporting'' should be an integer instead of ASCII character. Such incorrect syntax will lead to ''500'' error for the site. | + | The error reporting syntax in the .htaccess **php_value** override is incorrect. If it is set in php.ini, it should be ''error_reporting = E_ALL'', but if it is an override in the Apache conf or .htaccess, ''error_reporting'' should be an integer, and not ASCII characters. Such incorrect syntax will lead to a ''500'' error for the site. |
The corrrect override syntax should be: | The corrrect override syntax should be: | ||
php_value error_reporting 32767 | php_value error_reporting 32767 | ||
- | Here ''32767'' in apache conf or .htaccess means ''E_ALL'' in php.ini. After the above change, php error reporting works fine and php fatal error shows in both browser and php error log. | + | Here ''32767'' in Apache conf or .htaccess is equivalent to ''E_ALL'' in php.ini. After the above change, PHP error reporting should work fine and PHP should report a fatal error for ''test.php'' in both the browser and the error log. |