剛接觸php不久,碰到include和require, 在網上查了很久,很多人也做了比較,有些不大正確,有誤導之嫌,最權威的正確的答案在這裡:http://cn. php.net/manual/zh/function.include.php。
看瞭如果還不明白的話,我做了以下測試,
情況一:
include("./est.php"); // est.php不存在
echo "
. ..";
?>
測試結果:
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...";
?> echo "
continue...";
?> echo "
continue...";
?> echo "
continue...";
. 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字串沒有印出來。