在 Windows 中,getPathname 可能會傳回混合反斜線和正斜線的路徑('C:/some/path/to\a\file.txt')。在 PHP 5.2.9 中觀察到此現象。相比之下,getRealPath 會傳回一致的結果(全部為反斜線)。
(PHP 5 >= 5.1.2, PHP 7, PHP 8)
SplFileInfo::getPathname — 取得檔案的路徑
此函式沒有參數。
檔案的路徑。
範例 #1 SplFileInfo::getPathname() 範例
<?php
$info = new SplFileInfo('/usr/bin/php');
var_dump($info->getPathname());
?>
上述範例將輸出類似以下的內容
string(12) "/usr/bin/php"