• 首页
  • css3教程
  • html5教程
  • jQuery手册
  • php7教程
  • MySQL手册
  • apache手册
  • 位置: php7教程 -> php7语言

    php7预定义异常类Exception

    Exception是所有异常的基类。

    Exception
    {
    	/* 属性 */
    	protected string $message ;
    	protected int $code ;
    	protected string $file ;
    	protected int $line ;
    	/* 方法 */
    	public __construct ([ string $message = "" [, int $code = 0 [, Throwable $previous = NULL ]]] )
    	final public getMessage ( void ) : string
    	final public getPrevious ( void ) : Throwable
    	final public getCode ( void ) : int
    	final public getFile ( void ) : string
    	final public getLine ( void ) : int
    	final public getTrace ( void ) : array
    	final public getTraceAsString ( void ) : string
    	public __toString ( void ) : string
    	final private __clone ( void ) : void
    }
    

    属性

    • message:异常消息内容
    • code:异常代码
    • file:抛出异常的文件名
    • line:抛出异常在该文件中的行号
    Lists of Throwable and Exception tree as of 7.2.0
        Error
          ArithmeticError
            DivisionByZeroError
          AssertionError
          ParseError
          TypeError
            ArgumentCountError
        Exception
          ClosedGeneratorException
          DOMException
          ErrorException
          IntlException
          LogicException
            BadFunctionCallException
              BadMethodCallException
            DomainException
            InvalidArgumentException
            LengthException
            OutOfRangeException
          PharException
          ReflectionException
          RuntimeException
            OutOfBoundsException
            OverflowException
            PDOException
            RangeException
            UnderflowException
            UnexpectedValueException
          SodiumException
    Find the script and output in the following links:
    https://gist.github.com/mlocati/249f07b074a0de339d4d1ca980848e6a
    https://3v4l.org/sDMsv
    posted by someone here http://php.net/manual/en/class.throwable.php