How to display PHP errors in the browser without php.ini access or log access
Posted by Support, Last modified by Support on 09 July 2015 06:33 PM

How to display PHP errors in the browser for debugging when you don't have access to the servers php.ini file or the servers log files.

Insert the below PHP code into the PHP file you want to debug, then this will report all PHP errors to the browser when accessing the PHP page.

ini_set("display_errors", 1);

If you want to debug a whole site or muliple pages then edit the file (or create it if it does not already exist) /html/.user.ini and add the following:

error_reporting = E_ALL & ~E_DEPRECATED
display_errors = On
display_startup_errors = On


Another option is to enable error logging directly to your account, although make sure to disable this or it may use up all your web site disk space:

Put the following into the .htaccess file (or create one if it does not already exist) in the root folder of the site in question (usually /html):

php_flag log_errors on
php_value error_log /var/www/vhtdocs/userwebXXXXX/error_log

Replace XXXXX above with your actual user account number. With the example above the apache/php error log will be next to the html folder when you FTP/SSH into your account.

(857 vote(s))
Not helpful