Code has been added to clipboard!
Logging PHP Errors
Example
<?php
//error handler function
function custom_error($err_no, $err_str) {
echo "<b>Error caught!</b> [$err_no] $err_str<br>";
echo "Site owner notified";
error_log("Error caught! [$err_no] $err_str", 1, "[email protected]", "From: [email protected]");
}
//set error handler
set_error_handler('custom_error', E_USER_WARNING);
//trigger error
$test = 2;
if ($test >= 1) {
trigger_error('Value has to be 1 or lower', E_USER_WARNING);
}
?>