PHP error handling and exception handling

Source: Internet
Author: User
Tags bitwise operators php error throw exception

1. Set your own error-handling function

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/83/CB/wKioL1d8qEmARWb-AABRRC0FX_o132.png-wh_500x0-wm_3 -wmp_4-s_994699171.png "title=" 00.png "width=" "height=" 368 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:500px; height:368px; "alt=" Wkiol1d8qemarwb-aabrrc0fx_o132.png-wh_50 "/>

Trigger_error () captures user-level errors. Set_error_handler () user-defined error handling function.

2. Catching exceptions

Catching exceptions of course with try{

A function with an exception is placed here, no exception, code continues execution, exception is triggered, an exception is thrown

}catch () {


}

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/83/CD/wKiom1d8qxzQ0tg6AACFYeo85U8447.png-wh_500x0-wm_3 -wmp_4-s_3882888638.png "title=" 01.png "alt=" Wkiom1d8qxzq0tg6aacfyeo85u8447.png-wh_50 "/>

Of course, the exception handling class used in the code is thinkphp, Throw_exception is the thinkphp throw exception function



In addition to the PHP error mechanism to add:


650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/83/CD/wKiom1d8rhaAoODJAAGcl9UUM5Q257.png-wh_500x0-wm_3 -wmp_4-s_2956218205.png "title=" 02.png "alt=" Wkiom1d8rhaaoodjaagcl9uum5q257.png-wh_50 "/>


the value above (numeric or symbolic) is used to create a bits mask, To create the error message to report. You can use bitwise operators to combine these values or to mask some types of errors. note that in  php.ini , only ' | ', ' ~ ', '! ', ' ^ ' and ' & ' will parse correctly.



This article is from "I want to be a Daniel" blog, please make sure to keep this source http://houhaibo.blog.51cto.com/10674676/1808953

PHP error handling and exception handling

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.