current_dir()

2018-06-13 18:10 更新

作用:獲取當(dāng)前目錄路徑。

語(yǔ)法: string current_dir([string $filename])

參數(shù)$filename 當(dāng)前目錄下的文件。

返回值

如果未提供參數(shù),則返回當(dāng)前目錄路徑 如果提供 $filename 參數(shù),則返回 $filename 的路徑。

說(shuō)明

DIR 常量不同,DIR 的值始終是它所在文件的名稱,而 current_dir() 則返回它被調(diào)用時(shí)的文件的名稱。

示例

<?php
echo current_dir(); //輸出當(dāng)前目錄路徑
echo current_dir('test.php'); //輸出當(dāng)前目錄下 test.php 文件的路徑
以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)