作者JYHuang (夏天到了,冷不起來了說)
看板PHP
標題Re: [請益] 根目錄的路徑?
時間Wed Dec 9 22:18:56 2009
說到這個我想想到一個滿好玩的情形提出來分享一下
目前手上有一個網站我是用include($tmp_path."/".$template.".php")
的方式來引入樣板檔案。
有時template.php裡還會再引入其它的樣板檔案。
程式碼如下
# main.php
include(/temp/template.php)
# template.php
include(template1.php)
如果此時的檔案是這樣配置的
/
main.php
/
temp/
template.php
template1.php
main.php可以正確的引入template.php再引入template1.php
不過當檔案這樣配置時
/
main.php
/
template1.php
/
temp/
template.php
也是一樣可以運作的是也
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.104.153.57
推 JoeHorn:include 不會噴 error,當然可以運作,輸出結果就有差了.. 12/09 23:13
→ JYHuang:我的意思是,include的內容一樣會輸出 12/09 23:50
→ JoeHorn:include_path ... 12/10 00:38
→ JYHuang:/temp跟/都不在include_path內喔 12/10 09:19
→ AndCycle:include_path 裡那個 . 就是檔案所在的目錄 ... 12/10 16:02
推 tkyifang:是的 多層的include 每個目錄都會被當作當前目錄尋找檔案 12/10 21:59