What is the difference between introducing include and require into files in php
This article will explain in detail what are the differences between include and require in php files. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Php files introduce (load) the difference between include and require
Description: file loading can be php file or html file
Loading methods: include and require include_once and require_once
There are two results loaded in:
1. The contents of the file are loaded and run
If loading content: include 'File path to load'
Include 'mysqldb.php'
two。 Get return data
If it is data include ('File path to get data')
/ / get data define ('ROOT',str_replace ('\\','/', _ _ DIR__).); $res = include (ROOT.'config.php')
Note:
The path must be written to the folder directory, and the complete path must be written (which can be obtained with _ DIR_)
The difference between Include and require:
The level of error is different, resulting in different results after running errors.
If an error occurs in include, it does not affect the running of the code on the current page of the program.
If there is an error in require, it will affect the running of the code of the program and will not be executed further.
The difference between not adding once and adding once:
The way to add once will only be introduced once no matter how many times a file is introduced.
The way not to add once is to run the code as many times as you import the file.
On "what are the differences between include and require in php files?" this article ends here. I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.