php获取当前目录的方法是什么
要获取当前目录的方法是使用PHP中的__DIR__
或者dirname(__FILE__)
。
- 使用
__DIR__
:
$currentDirectory = __DIR__;
echo $currentDirectory;
- 使用
dirname(__FILE__)
:
$currentDirectory = dirname(__FILE__);
echo $currentDirectory;
这两种方法都会返回当前文件所在的目录路径。
相关问答