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 Postedon2007-09-2913: 38YemooSPHPHome read (13988) comment (0 )? Edit? Collection Reference Category: PHP Basics & lt ;! -- & Lt; difference between include () and require () in rdf PHP: RDFxmlns

Difference Between include () and require () in PHP Posted on Yemoo's PHP Home Read (13988) Comments (0 )? Edit? Collection Reference Network Abstract Category: basic PHP knowledge

I haven't touched php for a long time, and even forgot some basic things. I read the php document today and see the difference between include and require, I feel this is a very confusing place for beginners. I will record it here for your reference and hope it will be helpful to php friends.

There are two methods to reference files: require and include. The two methods provide different elasticity.

The use of require is as follows:require("MyRequireFile.php");. This function is usually placed at the beginning of the PHP program. before the PHP program is executed, it will first read the file specified by require to make it a part of the PHP program webpage. This method can also be used to introduce common functions into webpages.

The use of include is as follows:include("MyIncludeFile.php");. This function is generally placed in the process of process control. The PHP program webpage reads the include file. In this way, you can simplify the process during program execution.

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.