difference between require () and include ()-Excerpt from net Monkey

Source: Internet
Author: User
Tags functions header include require
Include| distinguishes the use of header files in PHP, which involves two functions: include () and require (). These two functions are very small, but very important, so we have to study carefully. The Require () function works like a xssi, and regardless of which part of the program is used, the contents of the header file are processed as part of the program itself, as soon as the program starts running. Therefore, if you use the Require () function in a conditional decision statement, the header file is included even if the condition is not true.

The Include () function only contains the contents of the head file when executing to this statement. If the program is not running here, PHP will not be able to control it. This means that when you use include in the Conditional decision section, it works exactly the way you want it to.

Also, if you use the Require () function and the header file you specified does not exist, the program will stop running and produce an error. If you use include (), the program will produce a warning message, but it will continue to run.


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.