首页 > Web开发 > 详细

PHP 异常与错误 —— RuntimeException

时间:2018-07-19 20:04:20      阅读:486      评论:0      收藏:0      [点我收藏+]

RuntimeException

官方文档地址: http://php.net/manual/en/class.runtimeexception.php

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

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

 

class RuntimeException extends Exception implements Throwable { // PHP 7 支持 Throwable 接口

  /* 继承属性 */
  protected string $message; // 异常信息
  
  protected int $code; // 错误代码
  
  protected string $file; // 出错文件
  
  protected int $line; // 出错行号
  
  
   /* 方法 */
  public __construct ([ string $message = "" [, int $code = 0 [, Exception $previous = NULL ]]] ) // 构造一个异常
  
  public __construct ([ string $message = "" [, int $code = 0 [, Throwable $previous = NULL ]]] ) // PHP 7
  
  /* 继承方法 */
  final public string Exception::getMessage ( void ) // 获取抛出的消息内容

  final public Throwable Exception::getPrevious ( void ) // 返回上一个 Throwable

  final public mixed 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 ) // 尝试克隆异常,将导致一个致命错误

}

 

PHP 异常与错误 —— RuntimeException

原文:https://www.cnblogs.com/wengyingfeng/p/9337739.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!