Display errors in PHP file

If you see just a blank page, chances are you have error in your PHP that you can’t see. Using these few lines you’ll be able to see the issue.

Display errors by adding code to PHP file

The easiest way to display errors in PHP file is by adding following 3 lines either at the beginning of file, or before the snippet you think is causing the issue.

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

Display errors by updating .htaccess file

Add following lines to .htaccess ( preferably before redirect settings, look for RewriteRule )

php_flag display_startup_errors on
php_flag display_errors on
php_value error_reporting 32767
php_flag html_errors on

32767 equals to E_ALL, see http://php.net/manual/en/errorfunc.constants.php

Also, make sure you have

display_errors = on

in your php.ini ( usually /etc/php5/apache2/php.ini, or C:/windows/php.ini )

Write a Comment