PHP error_reporting() function

This is used to report the error. This returns the errors of script at the run time based on the given error type.

Syntax

error_reporting(level);

These are the different types of error levels

To turn off all errors = ERROR_REPORTING(0);
To display only warning = ERROR_REPORTING(E_WARNING);
To display only parse errors = ERROR_REPORTING(E_PARSE);
To display all types of errors = ERROR_REPORTING(E_ALL);
To display only notice error type = ERROR_REPORTING(E_NOTICE);
To hide notice and display all the other errors = ERROR_REPORTING(E_ALL & ~E_NOTICE);


Example

<?php
   // report all error except notice	
   error_reporting(E_ALL & ~E_NOTICE);

   // turn off error reporting	
   error_reporting(0);
   
   // report runtime errors 
   error_reporting(E_ERROR | E_WARNING | E_PARSE);
   
   // report all errors
   error_reporting(E_ALL);
?>



Read more articles


General Knowledge



Learn Popular Language