我怀疑glob
需要当前工作目录才能工作,因此您可以尝试将文件的完整路径传递给现有函数。。。
include_all_php(dirname(__FILE__).\'/includes\');
或先设置当前工作目录:
setcwd(dirname(__FILE__).\'/\');
include_all_php(\'includes\');
或者,您也可以使用
scandir
:
$filepath = dirname(__FILE__).\'/includes/\';
$files = scandir($filepath);
foreach ($files as $file) {
// match the file extension to .php
if (substr($file,-4,4) == \'.php\') {include($filepath.$file);}
}