2017-04-03 63 views
-5

我想獲取包含在給定路徑的文件中的文件的名稱/路徑。但是get_included_files()函數僅適用於寫入它的文件。get_included_files()爲定義的路徑

<? 
    include_once('/folder1/folder2/xyz.php'); 
    $path = '/abcd.php'; 
    $includeFiles = get_included_files(); 
?> 

我已經嘗試了上面的代碼,我只在這個文件中只包含文件。 我想獲取abcd.php中包含文件的名稱,即定義的路徑。

請幫助!

+0

有一個關於'get_included_files()有用[文件](http://php.net/manual/en/function.get-included-files.php);',你看過嗎? – Jer

回答

0

這樣的事情呢?

array_filter(get_included_files(), function($item) { 
    return strpos($item, '/path/to/files/') === 0;                
});