php glob()替代方案
我有一个使用glob()函数的wordpress主题。问题是我的托管公司已禁用glob()。如何修改代码以使其使用其他php函数(可能是opendir())工作 代码如下:php glob()替代方案,php,wordpress,Php,Wordpress,我有一个使用glob()函数的wordpress主题。问题是我的托管公司已禁用glob()。如何修改代码以使其使用其他php函数(可能是opendir())工作 代码如下: function yiw_get_tabs_path_files() { $theme_files_path = YIW_THEME_FUNC_DIR . 'theme-options/'; $core_files_path = YIW_FRAMEWORK_PATH . 'theme-options/o
function yiw_get_tabs_path_files() {
$theme_files_path = YIW_THEME_FUNC_DIR . 'theme-options/';
$core_files_path = YIW_FRAMEWORK_PATH . 'theme-options/options/';
$tabs = array();
foreach ( glob( $theme_files_path . '*.php' ) as $filename ) {
preg_match( '/(.*)-options\.(.*)/', basename( $filename ), $filename_parts );
$tab = $filename_parts[1];
$tabs[$tab] = $filename;
}
foreach ( glob( $core_files_path . '*.php' ) as $filename ) {
preg_match( '/(.*)-options\.(.*)/', basename( $filename ), $filename_parts );
$tab = $filename_parts[1];
$tabs[$tab] = $filename;
}
return $tabs;
}您可以根据需要使用和的组合 建议
// open the directory
if ($handle = opendir($file_path)) {
// iterate over the directory entries
while (false !== ($entry = readdir($handle))) {
// match on .php extension
if (preg_match('/\.php$/', $entry) {
...
}
}
// close the directory
closedir($handle);
}
如果这些也被禁用,您可以尝试使用面向对象类。您可以使用和的组合 建议
// open the directory
if ($handle = opendir($file_path)) {
// iterate over the directory entries
while (false !== ($entry = readdir($handle))) {
// match on .php extension
if (preg_match('/\.php$/', $entry) {
...
}
}
// close the directory
closedir($handle);
}
如果这些也被禁用,您可以尝试使用面向对象类。您是否有充分的理由相信您的主机将启用其他文件系统功能?@Ibrahim:然后尝试运行任何调用opendir的代码?好,如何在上面的代码上实现它?你有没有充分的理由相信你的主机将启用其他文件系统功能?@Ibrahim:然后尝试运行任何调用opendir的代码?好的,如何在上面的代码上实现它?