Re: [請益] include與require的差異在於引入外部檔 …

看板PHP作者 (每天都在公司玩OLG)時間16年前 (2009/08/23 02:26), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/6 (看更多)
官方手冊裡面有這段: 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.║║║║. .  ╰══╯ ╰══╯╰══╯╰═╯ ╰╯╰══╯╰╯ ╰╯╰╯By meei0531 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.254.19.103
文章代碼(AID): #1Aa3XOJe (PHP)
討論串 (同標題文章)
文章代碼(AID): #1Aa3XOJe (PHP)