Require all files in a folder

后端 未结 9 1422
南旧
南旧 2020-12-28 13:13

Is there an easy way to programmatically require all files in a folder?

9条回答
  •  天命终不由人
    2020-12-28 13:23

    Probably only by doing something like this:

    $files = glob($dir . '/*.php');
    
    foreach ($files as $file) {
        require($file);   
    }
    

    It might be more efficient to use opendir() and readdir() than glob().

提交回复
热议问题