How to display PHP errors

OpenCartBot - 31 July 2022
How to display PHP errors

In a short article, we will tell you how to enable the display of PHP errors on the screen. This is necessary for debugging the script, identifying all problems: recommendations, warnings (notices), errors.

To display PHP errors, add the following code at the beginning of the executable script:

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

To display errors on the entire site, add the following code to the .htaccess file at the root of the site:

php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_value docref_root 1
php_value docref_ext 1

Another way to display the PHP error code is to add the following lines to the php.ini configuration file at the root of the site:

display_errors = 1;
error_reporting = E_ALL;

Debugging is a mandatory procedure before releasing a script or for fixing errors, but do not forget to turn off the display of errors after debugging is done, so as not to inconvenience users in the form of unclear text or code on the page.


Products related to this post


Related Posts