![](/img/trans.png)
[英]PHP getcwd() function to be used with include or require in different directories
[英]php getcwd() - exclude server directories
我有以下幾行代碼可在我的本地計算機上使用,因為服務器的根目錄與站點的根目錄相同。
$directories = explode("/", str_replace($_SERVER['DOCUMENT_ROOT'] . "/", "", getcwd()));
我該如何使其適應我的刪除服務器,因為該服務器的根目錄比站點的目錄低幾個級別。 我想我只需要包括站點目錄,而不是服務器目錄。
我的邏輯表明,您需要在此處放置遠程服務器地址:
$directories = explode("/here/", str_replace($_SERVER['DOCUMENT_ROOT'] . "/", "", getcwd()));
如果那行不通,請檢查這些線程,我認為您的解決方案就是其中之一
因此線程: 根路徑不適用於php include
Tech-Recipes-Thread: PHP:確定服務器根目錄的目錄路徑
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.