This is an old revision of the document!
Why PHP error reporting not working?
A user tries to enable PHP error reporting for PHP code troubleshooting. From the phpinfo.php page, seems the local values are correct.
display_errors On display_startup_errors On error_log php_error.log error_reporting E_ALL
Create a test script test.php like the following:
<?php echo zzzzzxzzzzxd('test'); ?>
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.
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
.
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 corrrect override syntax should be:
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.