首頁  >  文章  >  後端開發  >  php include 和 require區別

php include 和 require區別

巴扎黑
巴扎黑原創
2016-11-23 15:07:241029瀏覽

剛接觸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字串沒有印出來。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn