Include and require in PHP

Source: Internet
Author: User
: This article mainly introduces include and require in PHP. For more information about PHP tutorials, see. 1. what is the purpose?

Server Side Include (SSI) is used to create functions, headers, footers, or elements that can be reused on multiple pages. Including files reuse files, saving a lot of work.

II. how to use it?

Include 'filename ';
Or
Require 'filename ';

1. php



  

2. php



  

Access 1. php in the browser (note that 1. php and 2. php are stored in the same folder ):Hello World.

III. what is the difference between include and require?

In terms of error handling:
Require generates a fatal error (E_COMPILE_ERROR) and stops the script.
Include only generates warnings (E_WARNING), and the script continues

Use:
Please use require at this time: when the file is requested by the application.
Please use include at this time: when the file is not required and the application should continue to run when the file is not found.

Copyright Disclaimer: This article is an original Lshare article. if you need to reprint it, please contact me. if you have any questions, please comments or private messages.

The above introduces include and require in PHP, including some content, and hope to be helpful to friends who are interested in PHP tutorials.

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.