小编Jam*_*son的帖子

有没有办法将这个PHP放入一个数组并简化它?

以下代码加载在指定文件夹中找到的所有.php文件(单独定义).有没有办法将其放入数组以简化代码?

只有几个变量发生了变化,但基本上代码重复了几次.

// The General Files

$the_general = opendir(FRAMEWORK_GENERAL);

while (($the_general_files = readdir($the_general)) !== false) {
    if(strpos($the_general_files,'.php')) {
        include_once(FRAMEWORK_GENERAL . $the_general_files);       
    }       
}

closedir($the_general);


// The Plugin Files

$the_plugins = opendir(FRAMEWORK_PLUGINS);

while (($the_plugins_files = readdir($the_plugins)) !== false) {
    if(strpos($the_plugins_files,'.php')) {
        include_once(FRAMEWORK_PLUGINS . $the_plugins_files);       
    }       
}

closedir($the_plugins);
Run Code Online (Sandbox Code Playgroud)

还有几个部分调用不同的文件夹.

任何帮助是极大的赞赏.

干杯,詹姆斯

php wordpress

5
推荐指数
2
解决办法
328
查看次数

标签 统计

php ×1

wordpress ×1