Difference between require and include in PHP

Source: Internet
Author: User

Using the header file in PHP involves two functions: Include () and require (). These two functions have very little difference, but they are very important. So we need to study them carefully.
The require () function works in a similar way as xssi;ProgramWhich part of the file uses this function. Only when the program starts to run, the header file content is used as part of the program itself.
. Therefore, if you use the require () function in a condition determination statement, the header file will be included even if the condition is not true.

The include () function only includes the header file content when this statement is executed. If the program does not run here, PHP will not care about it. This means that when you use include in the condition determination part, it will work exactly as you want.

In addition, if you use the require () function and the header file you specified does not exist, the program stops running and produces errors. If you use include (), the program generates a warning message, but continues 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.