PHP5 exception handling mechanism [7] - PHP5 built-in Exception class

xiaoxiao2021-03-06  90

PHP5 exception mechanism

According to the above discussion, PHP built-in exceptions need to have the following members:

__construct () constructor, require an error message and an optional integer error mark as a parameter getMessage () gets the error message getCode () error code getFile () unusible file getLine () exceptional line number GetTrace ( ) Tracking the route passing through each step, depositing an array, returning the array getTraceAsstring () and getTrace () functions, but you can convert the elements in the array to a string and output in a certain format.

It can be seen that the structure of the Exception class is similar to Pear_Error. When you encounter an error in your script, you can build your exception object:

$ EX = New Exception ("COULD NOT OPEN $ THIS-> File");

The constructor of the Exception class will accept an error message and an error code.

转载请注明原文地址:https://www.9cbs.com/read-121829.html

New Post(0)