PHP contains the difference between the file statement include and require

Source: Internet
Author: User

The role of include and require is to insert the contents of the PHP file into another PHP program before the server executes it.

The syntax is the same (both language constructs), and the difference is in dealing with errors: require generates a fatal error and stops execution, and the include generates only a warning and resumes execution of the script.

The reason: Require this language structure is usually placed at the top of the PHP program, the PHP program before execution, will be read into the require specified by the introduction of the file to make it a part of the PHP program; Include this language structure is generally placed in the process control of the processing section, When the PHP program reads the include file, it is read in, which simplifies the process of executing the program.

General recommendations for global content use require at the beginning of the program. Use include when it is used.

The different processing methods after an error result in a slightly different usage, and if you want to continue and output the results to the user, use include if the included files are missing, or if the included files are important, or to ensure page completion and security, then use require.
The difference between require_once and require (Inlcude and include_once)
The role of _once is to prevent multiple calls to the same file, increasing the burden on the server.

PHP contains the difference between the file statement 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.