It is quite normal for our code to have minor errors. Although such errors do not affect the execution of our code, PHP still displays them. A lot of times, this distorts the design of our websites. In this shot, we'll see how to turn error reporting off in PHP.
To successfully turn off error reporting in PHP, we use the error_reporting()
function.
<?phperror_reporting(0);trigger_error("user warning!", E_USER_WARNING);echo 'no errors';?>
error_reporting(0)
to turn off all error reporting in our codetrigger_error(“user warning!”, E_USER_WARNING)
. However, because we have used error_reporting(0)
, the error isn't reported.