php include 跟 require区别
程序员文章站
2024-02-17 16:57:52
...
php include 和 require区别
刚接触php不久,碰到include和require, 在网上查了很久,很多人也做了比较,有些不大正确,有误导之嫌,最权威的正确的答案在这里:http://cn.php.net/manual/zh/function.include.php。
看了如果还不明白的话,我做了以下测试,
情况一:
include("./est.php"); // est.php不存在
echo "
continue...";
?>
测试结果:
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...
情况二:
require("./est.php");
echo "
continue...";
?>
测试结果:
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
此处continue字符串没有打印出来。
刚接触php不久,碰到include和require, 在网上查了很久,很多人也做了比较,有些不大正确,有误导之嫌,最权威的正确的答案在这里:http://cn.php.net/manual/zh/function.include.php。
看了如果还不明白的话,我做了以下测试,
情况一:
include("./est.php"); // est.php不存在
echo "
continue...";
?>
测试结果:
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...
情况二:
require("./est.php");
echo "
continue...";
?>
测试结果:
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
此处continue字符串没有打印出来。
相关文章
相关视频
上一篇: php怎么读取Cookie