PHP learning: the difference between include () and require ()

Source: Internet
Author: User
The difference between include () and require () is believed to be the most basic problem in PHP. it is also a mandatory question for many companies during interviews. Review: require (): If the file does not exist, a fatalerror is reported. stop executing include (): If the file does not exist, a warning is provided, but the script continues to be executed. Note that when the include () file does not exist, the script continues to be executed, in this case, the difference between include () and require () is believed to be the most basic problem in PHP. it is also a must-have question for many companies during interviews.

Let's review:

Require (): If the file does not exist, a fatal error is reported. The script is stopped.
Include (): If the file does not exist, a warning is provided, but the script continues to run.

Note:
When the include () file does not exist, the script continues to be executed. this occurs only before PHP 4.3.5, which is often ignored.

We recommend that you use require_once () and include_once () to check whether the file contains duplicates.

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.