error_reporting() is an inbuilt function of PHP (hypertext preprocessor) language. It is used to turn off the reporting of errors and warnings.
Sometimes, we need to make use of it as not to get unnecessary errors. For example, when you define conditions in if(condition), if that does not produce true, then your else statement will execute and return errors.
Now, using error_reporting() function, you can make error reporting disabled. To turn off all types of error reporting in PHP, pass 0 as a parameter of error_reporting() function.
error_reporting() function Syntax
error_reporting() function Example
Here, in this below example, I have linked an external PHP file that does not exist at all. You know that when PHP is not able to find it then produces error and warning.
But, I used error_reporting(0) function and turned off the reporting.
<?php error_reporting(0); require("external.php"); ?>
Publish A Comment