PHP 异常与错误 —— InvalidArgumentException

InvalidArgumentException

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

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

当参数不是预期的类型时,抛出 InvalidArgumentException 。继承 LogicException ,继承 Exception , PHP 7 引用接口 Throwable 。

 

class InvalidArgumentException extends LogicException 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 ) // 尝试克隆异常,将导致一个致命错误

}

 

转载于:https://www.cnblogs.com/wengyingfeng/p/9324488.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值