PHP Conference Japan 2024

RecursiveDirectoryIterator::getSubPathname

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

RecursiveDirectoryIterator::getSubPathname取得子路徑和名稱

說明

public RecursiveDirectoryIterator::getSubPathname(): 字串

取得子路徑和檔名。

參數

此函式沒有參數。

回傳值

子路徑(子目錄)和檔案名稱。

範例

範例 #1 getSubPathname() 範例

$directory = '/tmp';

$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));

foreach ($it as $file) {
echo '子路徑名稱:' . $it->getSubPathname() . "\n";
echo '子路徑:' . $it->getSubPath() . "\n\n";
}

上述範例將輸出類似以下的內容

SubPathName: fruit/apple.xml
     SubPath:     fruit
     
     SubPathName: stuff.xml
     SubPath:     
     
     SubPathName: veggies/carrot.xml
     SubPath:     veggies

另請參閱

新增註解

使用者貢獻的註解

此頁面沒有使用者貢獻的註解。
To Top