July 9, 2014

Display and show PHP 500 internal server error

When you are working with PHP and sometime the browser is showing nothing but with HTTP Status code 500. It means there is an internal server error which causing by fatal error in your codes. It is difficult to identify the root cause without exception message when debugging. Therefore, we can show the exception message by changing the error display setting. There are two ways to enable this error display.

1. Modify the error display setting in php.ini

Change the setting as below in php.ini file.


display_errors = On
error_reporting = E_ALL | E_STRICT

2. Override the error display setting in runtime

When you are not allowed to modify the php.ini file, but would like to show the errors. We can change the setting in code level during runtime to override the setting in php.ini file. The codes should be inserted to the very beginning in your PHP file.


ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);

PS : remember to turn off those setting in your production environment.

No comments:

Post a Comment