The difference between include and require in PHP

Source: Internet
Author: User

  Require, such as: Require ("myfile.php"), require statements are usually placed at the very front of the PHP script. Before the PHP program executes, it will read into the file introduced by the Require () statement, making it part of the php script file.

Include uses the same method as require, such as include ("myfile.php"), while the include statement is generally placed in the Process Control section. The php script file is read into the include () statement before the file it contains. This way, you can simplify the process of executing the program.


The include is loaded when it is used.

  Simply put, require is loaded at the beginning; Loaded when the include is used.

In addition, when the include introduces a file, if it encounters an error, it will give a hint and continue to execute the code below; Require when the file is introduced, if it encounters an error, it will give a hint and stop running the code below.
The Require and include plus _once suffixes indicate that the load is not loaded.

The difference between include and require in PHP

Related Article

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.