i have my own error_handler:
$error = new Error();
set_error_handler(array($error,"catchError"));
class Error{
public function catchError($err_no, $err_str, $err_file, $err_line, $err_context){
print_r($err_no);
}
}
If i cause error of type "E_WARNING" this error catcher writes just "2". How i force him to write "E_WRNING"?
I wonder, if is possible get error name from this "2" code. Thank you very much!
switch ($err_no) {
case E_WARNING :
echo 'E_WARNING';
break;
case E_NOTICE :
echo 'E_NOTICE';
break;
...
}
Alternatively an array:
$errors = array(
E_WARNING => 'E_WARNING',
E_NOTICE => 'E_NOTICE',
...
);
echo $errors[$err_no];
For all types you want to handle from this list: http://php.net/manual/en/errorfunc.constants.php
Typically you'd handle different error levels differently, not just echo
the name of the constant.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.