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.