Display Errors in PHP.

In a Php Application, different types of errors and warnings occurred while the time of runtime or compile time. Thus, PHP has four ways to show these errors and warnings in the script as follows:

  1. error_reporting: It displays all level errors except E-NOTICE, E-STRICT, and E_DEPRECATED level errors. The error_reporting is a native function of PHP. It is used to display errors.
  2. display_errors: In PHP By default, the value of display_errors is off. It needs to be set it on to display all the errors, including parse errors.
  3. log_errors: The default value of log_errors is ON, which indicates whether the error logging should be done or not.
  4. error_log string: The error_log string sets the file name where scripts error should be logged.

The following piece of code in PHP is used to display the errors. It’s a way to display all the PHP errors and warnings.

ini_set (‘display_errors’, 1);
ini_set (‘display_startup_errors’, 1);
error_reporting (E_ALL);

<?php  
    ini_set('display_errors', 1);   
    ini_set('display_startup_errors', 1);   
    error_reporting(E_ALL);   
    //include a php file that does not existing in the application  
    include("file.php");  
?>

As we have included a named file.php that does not exist in the PHP application and the following error will display in the output.

So, thanks for following this blog, and if you need any help please leave your queries in the comment box we will be happy to help you.

Display Errors in PHP.expoundsofttechsolution