Include and require in PHP

Source: Internet
Author: User
Tags stop script
Include and require in PHP 1. what is the purpose? ServerSideInclude (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& lt ;? Include and require in phpech PHP

1. what is the purpose?

Server includes(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:
RequireWill generate a fatal error (E_COMPILE_ERROR) andStop script
IncludeGenerates only warnings (E_WARNING) andThe script will continue

Use:
UseRequire: When an object isApplication requests.
UseInclude: When a fileNot RequiredAnd the application should continue running 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.

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.