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 ) // 嘗試克隆異常,將導致一個致命錯誤 }