Re: [請益] include與require的差異在於引入外部檔 …
首先感謝回覆
可是我將測試的程式改成
<?PHP
$b=true;
if($b==false) include("noexit.php");
echo "after";
?>
後
將include改成require或是維持原來的include
皆可以在browser顯示出after字串
請問是我這樣的測式方式有錯嗎
感謝回復
※ 引述《JoeHorn (每天都在公司玩OLG)》之銘言:
: 標題: Re: [請益] include與require的差異在於引入外部檔 …
: 時間: Sun Aug 23 02:26:29 2009
:
: 官方手冊裡面有這段:
:
: require() and include() are identical in every way except how they handle
: failure. include() produces a Warning while require() results in a Fatal
: Error. In other words, don't hesitate to use require() if you want a
: missing file to halt processing of the page. include() does not behave
: this way, the script will continue regardless. Be sure to have an
: appropriate include_path setting as well.
:
: 簡言之,差別在「若被引入的檔案不存在,之後的程式碼會不會繼續執行」。
:
: --
: 所以,原 po 您測試用的那組程式無法測出差異,因為之後沒有其他程式碼了。
:
: --
: .╭═════╮。. o 。 . 。╭═╮o╭╮。. o 。 . o o . 。 ╰● √ 。
: ╰═╗ ╔═╯╭══╮╭══╮║▍║. ║║╭══╮╭╮。. ╭══╮ ◥██◤o
: o 。║▍║。o║╭╮║║╭╮║║▍╚═╝║║╭╮║║╘═╮║╭╮║。 ◥◤ 。
: 。 ║▍║ 。 ║║║║║╰╯║║▍╔═╗║║║║║║╔═╯║║║║ o ∥ o .
: 。╭╯▃║o ║╰╯║║══╯║▃║。║║║╰╯║║║o。.║║║║. 。∥ . 。
: ╰══╯ ╰══╯╰══╯╰═╯ ╰╯╰══╯╰╯ ╰╯╰╯By meei0531
:
: --
: ※ 發信站: 批踢踢實業坊(ptt.cc)
: ◆ From: 122.254.19.103
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.232.229.63
→
08/23 07:16, , 1F
08/23 07:16, 1F
→
08/23 07:17, , 2F
08/23 07:17, 2F
→
08/23 09:46, , 3F
08/23 09:46, 3F
→
08/23 09:47, , 4F
08/23 09:47, 4F
→
08/23 09:48, , 5F
08/23 09:48, 5F
→
08/23 09:48, , 6F
08/23 09:48, 6F
→
08/23 09:49, , 7F
08/23 09:49, 7F
→
08/23 09:49, , 8F
08/23 09:49, 8F
推
08/23 13:03, , 9F
08/23 13:03, 9F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 6 篇):