PHP 异常与错误 —— ErrorException

ErrorException

官方文档地址: http://php.net/manual/zh/class.errorexception.php

PHP 支持版本: 5 >=5.1, 7

错误异常。继承 Exception , PHP 7 引用接口 Throwable 。

class ErrorException extends Exception implements Throwable { // PHP 7 支持 Throwable 接口
  
  /* 属性 */
  protected $severity; // 异常级别
  
  /* 继承属性 */
  protected string $message; // 异常信息
  
  protected int $code; // 错误代码
  
  protected string $file; // 出错文件
  
  protected int $line; // 出错行号

  
  /* 方法 */
  public __construct ([ string $message = "" [, int $code = 0 [, int $severity = E_ERROR [, string $filename = __FILE__ [, int $lineno = __LINE__ [, Exception $previous = NULL ]]]]]] ) // 构造一个错误异常
 
  final public int getSeverity ( void ) // 获取异常级别
  
  /* 继承方法 */
  
  final public string Exception::getMessage ( void ) // 获取抛出的消息内容
  
  final public Throwable Exception::getPrevious ( void ) // 返回上一个 Throwable
  
  final public int Exception::getCode ( void ) // 获取抛出的错误代码
  
  final public string Exception::getFile ( void ) // 获取产生异常的文件名
  
  final public int Exception::getLine ( void ) // 获取相关行号
  
  final public array Exception::getTrace ( void ) // 获取追踪信息,返回数组形式

  final public string Exception::getTraceAsString ( void ) // 获取追踪信息,返回字符串形式
  
  public string Exception::__toString ( void ) // 抛出的对象以字符串形式返回,可以用 echo 打印相应结果

  final private void Exception::__clone ( void ) // 尝试克隆异常,将导致一个致命错误
  
}

猜你喜欢

转载自www.cnblogs.com/wengyingfeng/p/9328348.html