PHP error_reporting() | Enable/Disable Error Reporting

The PHP error_reporting() function is used when we need to define what errors to be displayed. For example:

   echo "<BR>Before \$x<BR>";
   echo $x;
   echo "<BR>After \$x<BR>";

The output produced by above PHP example on error_reporting() function is shown in the snapshot given below:

php error reporting function

Notice the $x, that is not defined. But there is no error displayed in the web browser. It is because, I have turned off the reporting of all errors using the first statement, that is error_reporting(0);. But, if I remove this statement, then the output should be:

php error reporting turn off error

PHP error_reporting() Syntax

The syntax of error_reporting() function in PHP, is:


The level parameter is optional, used to specify the error reporting level. List of predefined error constants, that can be used to define level, are described in its separate article.

PHP Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube