How does PHP catch debude_once exceptions?

Source: Internet
Author: User
How does PHP capture the include_once error? How does PHP catch errors of include_once and require_once? If the file does not exist or there are compilation and other errors in the file, can it be captured? DEMO: try {& nbsp; include_once (& quot; tttt. php & quot;); how does PHP catch the include_once error?
How does PHP catch errors of include_once and require_once?

If the file does not exist or there are compilation and other errors in the file, can it be captured?

DEMO:
Try {
Include_once ("t/ttt. php ");
} Catch (Exception $ e ){
Echo 'caught exception: '. $ e-> getMessage ();
}


------ Solution --------------------
You can use this method as follows:
If (! File_exists ("t/ttt. php "))
{
Include_once ("t/ttt. php ");
}
The require_once error is a compile-time error, not a RUNTIME error, which cannot be captured.
------ Solution --------------------
You can use file_exists () to check if the file does not exist.
File program errors can be checked using isset, is _ series functions

------ Solution --------------------
Bangding
Not captured
Only read the error report
------ Solution --------------------
At the top of the page, no error reports will be reported, and require_once will be used each time. if this error occurs, you will see the error prompt on the page!
------ Solution --------------------
File_exists before processing...

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.