The difference between php include and require

巴扎黑
Release: 2016-11-23 15:07:24
Original
996 people have browsed it

Not long after I came into contact with PHP, I came across include and require. I searched online for a long time and many people made comparisons. Some of them were not quite correct and were misleading. The most authoritative and correct answer is here: http://cn. php.net/manual/en/function.include.php.
If you still don’t understand after reading it, I did the following test,
Situation 1:
include("./est.php"); // est.php does not exist
echo "
continue...";
?>

Test results:
Warning: include(./est.php): failed to open stream: No such file or directory in .../test1.php on line 2 Warning: include(): Failed opening './est.php' for inclusion (include_path='.:/usr/local/Cellar/php/5.3.10/lib/php') in .../test1.php on line 2
continue...

Case 2:
require("./est.php");
echo "
continue...";
?>

Test result:
Warning: require(./est.php): failed to open stream: No such file or directory in .../test1.php on line 2 Fatal error: require(): Failed opening required './est.php' ( include_path='.:/usr/local/Cellar/php/5.3.10/lib/php') in .../test1.php on line 2
The continue string is not printed here.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!