php中如何獲取檔案的正確路徑

2022-05-13 02:08:54 字數 791 閱讀 4705

以上面的為例子

//

我們這裡需要使用到 $_file

echo "";

print_r($_files);

echo $_server[

'document_root

']."

";//

獲取檔案伺服器的根目錄。

echo dirname(__file__)."

";//

獲取當前檔案的目錄;

echo __file__."

";//

獲取當前檔案的目錄和檔名。

echo basename(__file__);//

獲取當前檔案的目錄和檔名。

echo "

";

瀏覽器輸出結果為:

C Winform中如何獲取檔案路徑

獲取檔名方法 用system.io.path.getfilename和system.io.path.getfilenamewithoutextension 無副檔名 的方法 獲取檔案路徑方法 獲取當前程序的完整路徑,包含檔名 程序名 string str this.gettype assembly....

PHP 中獲取檔名及路徑

1.basename mnt img image01.jpg 函式 得到檔名 輸出結果為 image01.jpg.使用 basename uristring 我們可以得到乙個包含副檔名的檔名 如果不需要副檔名,也可以使用 basename uristring,extstring 過濾副檔名,僅僅返回...

PHP 中獲取檔名及路徑

1.basename mnt img image01.jpg 函式 得到檔名 輸出結果為 image01.jpg.使用 basename uristring 我們可以得到乙個包含副檔名的檔名 如果不需要副檔名,也可以使用 basename uristring,extstring 過濾副檔名,僅僅返回...