set_error_handler

It sets a user-defined function to handle errors

Example

<?php
function errorFunc($errno, $errstr, $errfile, $errline) {
echo $errstr.” on ” . $errfile .” at “. $errline;
}
set_error_handler(“errorFunc”);
$val=5;
if ($test>1)  trigger_error(“An error occured”);
?>

Output

Undefined variable: test on /var/www/test/index.php at 7

Share