2012-02-10 63 views
0

我有一個目錄'modules',它將包含用於web應用程序的不同模塊。我怎樣才能包含'模塊'文件夾中每個模塊的所有index.php?PHP - 讀取目錄幷包含所有index.php的

所以基本上和Wordpress加載插件的方式一樣。

這是 '模塊' 的文件夾的結構:

[modules] 
     [some-module] 
      - index.php 
      - functions.php 
      - other.php 
     [another-module] 
      - index.php 
      - stuff.php 
     [someother] 
      - index.php 
      - script.js 

謝謝!

回答

1

你想這樣做嗎?

<?php 

$indexes = glob('modules/*/index.php'); 

foreach ($indexes as $path) { 
    require_once $path; 
} 
相關問題