刚接触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怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号