Php pre-defined exception

Source: Internet
Author: User
Tags php basics
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.