Differences between includerequire in php

Source: Internet
Author: User
Includerequire differences in php 1. include generates a warning when introducing non-stored files and the script will continue to be executed,

Require may cause a fatal error and the script is stopped.

2. include () is a conditional include function, while require () is an unconditional include function.

3. include has a return value, while require does not

4. read and evaluate the files to be referenced during include () execution,
Require () only processes the file to be referenced once during execution (the file content to be referenced in actual execution replaces the require () statement)

It can be seen that if there is code containing one of these commands and code that may be executed multiple times, the use of require () is more efficient,
If different files are read each time the code is executed, or there is a loop through a set of file stacks, use include (),

Require is usually used. 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, make it a part of the PHP web page. This method can also be used to introduce common functions into webpages.

Include is usually used. This function is generally placed in the processing part of process control. The PHP program webpage reads the include file. In this way, you can simplify the process during program execution.

  • Incluce loaded when used

  • Require load at the beginning

  • _ Once suffix indicates that the loaded files are not loaded.

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.