扩展PHP内置的异常类
ErrorException extends Exception {
/* 属性 */
protected int $severity ;
/* 方法 */
public __construct ([ string
$message
= "" [, int $code
= 0 [, int $severity
= E_ERROR [, string $filename
= __FILE__ [, int $lineno
= __LINE__ [, Exception $previous
= NULL
]]]]]] )
final public getSeverity ( void ) : int
/* 继承的方法 */
final public Exception::getMessage ( void ) : string
final public Exception::getPrevious ( void ) : Throwable
final public Exception::getCode ( void ) : int
final public Exception::getFile ( void ) : string
final public Exception::getLine ( void ) : int
final public Exception::getTrace ( void ) : array
final public Exception::getTraceAsString ( void ) : string
public Exception::__toString ( void ) : string
final private Exception::__clone ( void ) : void
}
将错误导入自建异常类
使用set_error_handler()函数将错误导入我们刚才继承的内容异常类ErrorException中。<?php
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");
/* Trigger exception */
strpos();
?>
转载请注明来源网址:青锋建站-http://www.sjzphp.com/webdis/error_exception_1017.html