Posted on: 10.09.2020 Posted by: Alex D Comments: 0

Show php file errors. Enable PHP error display.

How to enable displaying PHP warnings and errors?

Used ini.php file

Enabling the display of all errors and warnings in the php.ini file.

error_reporting = E_ALL
display_errors = On
display_startup_errors = On

Where is the ini.php file located?

You can find out. I use the command phpinfo();. You will see a table of settings for the ini.php file.

Now find the parameter “Loaded Configuration File” and “Configuration File (php.ini) Path”. This is the path to the directory of the file ini.php.

Used php operators

You can enable the display of notifications and warnings by adding the following lines to the beginning of the required .php file:

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

Used .htaccess file

Enabling the output of all errors and warnings in the .htaccess file.

php_value display_errors 1
php_value display_startup_errors 1
php_value error_reporting E_ALL

The demo code file php.

This code does not define the $ par_b variable.

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

echo "<H2>Custom Code on Show Error PHP.</H2>";
$par_a = "This is par_a.";
echo '<DIV >'.$par_a.' '.$par_b.'</DIV>';

There is now a message on the page:

Notice: Undefined variable: par_b in /var/www/spage.me/html/info/example/0/show_error_ex1.php on line 29

Categories:

Leave a Comment