One, what is the use?
Server side contains (Server Side Include,ssi) is used to create functions, headers, footers, or elements that can be reused on multiple pages. The Include file reuses the file and saves a lot of work.
Second, how to use?
include ' filename ';
Or
require ' filename ';
1.php
<?phpecho"Hello ";include‘2.php‘;?>
2.php
<?phpecho "World.";?>
In the browser access 1.php will get (note that at this point 1.php and 2.php are placed 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 a warning (e_warning), and the script continues
Please use at this time:
Please use requireat this time: when the file is requested by the application .
Use includeat this point: when the file is not required , and the application should continue to run when the file is not found.
Copyright NOTICE: This article for Lshare original article, need to reprint please contact me, have questions welcome comments or private messages.
Include and require in PHP