Ciao.
Un banale esempio:
set_error_handlerCodice PHP:
<?php
function stringUpperCase($str) {
if (!is_string($str)) {
trigger_error("I need a string ;) ", E_USER_ERROR);
}
return strtoupper($str);
}
function myErrorHandler($errnum, $errmsg, $file, $lineno) {
if($errnum == E_USER_ERROR) {
print "error: $errmsg\n
";
print "file: $file\n
";
print "line: $lineno\n
";
exit();
}
}
$handler = set_error_handler('myErrorHandler');
$up= stringUpperCase(1);
?>
![]()