Documentation

Difference between revisions of "Managing PHP errors"

(Created page with "PHP errors are not displayed by default. If you want to show PHP errors you can add these line to a .htaccess file in the documentroot of your website. For example create a f...")
 
Line 1: Line 1:
PHP errors are not displayed by default. If you want to show PHP errors you can add these line to a .htaccess file in the documentroot of your website.
+
PHP errors are not displayed by default. If an error occurs, you will simply get a blank page. This is for security reasons: this way, an attacker doesn't know about possible vulnerabilities of your website. If you want to see PHP errors, you can log them to a file, or enable the display of errors.
  
For example create a file ~/www/.htaccess with this content:
+
= Logging errors to a file =
  
  php_value display_errors on
+
If your username is ''foobar'', create a <code>.htaccess</code> file (for example: <code>~/wwww/.htaccess</code>) with this content, if you are a regular user:
 +
php_flag log_errors on
 +
  php_value error_log /home/user/foobar/php_error.log
 +
 
 +
Or if you are an organization:
 +
php_flag log_errors on
 +
php_value error_log /home/org/foobar/php_error.log
 +
 
 +
= Displaying errors =
 +
 
 +
Create a <code>.htaccess</code> file (for example: <code>~/www/.htaccess</code>) with this content:
 +
php_flag display_errors on

Revision as of 07:59, 11 May 2014

PHP errors are not displayed by default. If an error occurs, you will simply get a blank page. This is for security reasons: this way, an attacker doesn't know about possible vulnerabilities of your website. If you want to see PHP errors, you can log them to a file, or enable the display of errors.

Logging errors to a file

If your username is foobar, create a .htaccess file (for example: ~/wwww/.htaccess) with this content, if you are a regular user:

php_flag log_errors on
php_value error_log /home/user/foobar/php_error.log

Or if you are an organization:

php_flag log_errors on
php_value error_log /home/org/foobar/php_error.log

Displaying errors

Create a .htaccess file (for example: ~/www/.htaccess) with this content:

php_flag display_errors on