Differences between include () and require () in PHP

Source: Internet
Author: User
Tags php basics
The difference between include () and require () in PHP

the difference between include () and require () in PHP

Posted on 2007-09-29 13:38 Yemoo ' S PHP HomeRead (13988) Comments (0)? Edit? Collection References NET pickCategory: PHP Basics

Haven't touched PHP for a long time, even some of the basic things are almost forgotten, see PHP document today, see the explanation of the difference between include and require, feel this for beginners is a very easy to confuse the place, in this record, so that their own review, but also hope that the PHP friends help.

There are two ways to refer to a file: Require and include. Two ways to provide different use elasticity.

The use of require is as follows require("MyRequireFile.php"); . This function is usually placed at the front of the PHP program, and before the PHP program executes, it is read into the file specified by require to make it a part of the PHP program's Web page. Commonly used functions, you can also use this method to introduce it into the Web page.

include usage methods such as include("MyIncludeFile.php"); . This function is usually placed in the processing part of the process control. The PHP Program page reads the include file before it is read in. This way, you can simplify the process when the program executes.

  • 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.