The difference between include and require

Source: Internet
Author: User

The require () function refers to the inclusion of the content as a part of the current file, so when the included file has a syntax error or the file does not exist, the current file of the PHP script is no longer executed.

The include () function is the equivalent of specifying the path to the file, which does not affect the program's operation when the contained file is in error.

First of all, in the include and require two literal meaning to realize! Include is included , require is needed !

It is easy to see the tone of emphasis is not the same! Require error report the program behind the error is not executing!
Include error is reported Waring! The following program continues execution!

And of course their derivative: include_once () require_once ();

PHP's official PHP manual for explanations

Require and include
almost exactly the same , in addition to handling the failure in a different way. Require
E_compile_error
Level of error. In other words will cause the script to abort and include
Only the warning (e_warning) is generated and the script continues to run.

Official explanation:
Require is identical to include except upon failure it would also produce a fatal e_compile_error level ERROR. In other words, it'll halt the script whereas include only emits a warning (e_warning

The difference between include and require

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.