PHP Basics pre-defined exceptions
1. Exception
(PHP 5> = 5.1.0)
Introduction
Exception is the base class of all exceptions.
Method
Exception: :__ construct-Exception constructor
Exception: getMessage-get Exception message content
Exception: getPrevious-returns the previous Exception in the Exception chain.
Exception: getCode-get Exception code
Exception: getFile-get the program file name with an Exception
Exception: getLine-get the row number of the code with an Exception in the file
Exception: getTrace-get Exception tracing information
Exception: getTraceAsString-obtains the Exception tracking information of the string type.
Exception ::__ toString-convert the Exception object to a string
Exception :__ clone-abnormal clone
2. ErrorException
(PHP 5> = 5.1.0)
Introduction
Error exception.
Example
Example #1 use the set_error_handler () function to host error messages to ErrorException
The output of the preceding routine is similar:
Fatal error: Uncaught exception 'ErrorException' with message 'Wrong parameter count for strpos()' in /home/bjori/tmp/ex.php:8Stack trace:#0 [internal function]: exception_error_handler(2, 'Wrong parameter...', '/home/bjori/php...', 8, Array)#1 /home/bjori/php/cleandocs/test.php(8): strpos()#2 {main} thrown in /home/bjori/tmp/ex.php on line 8
Method
ErrorException ::__ construct-exception constructor
ErrorException: getSeverity-obtains the severity of an exception.