以下函数在 PHP > 5.3 中有效,但在旧版本中出错。如何修改它以使其 5.2 安全?
function _iniloader_get_dirs($dir) {
$dirs = array_filter(scandir($dir), function ($item) use ($dir) {
return (is_dir($dir.'/'.$item) && $item != "." && $item != "..");
});
// Use array_values to reset the array keys:
return array_values($dirs);
}
5.2 错误:
解析错误:语法错误,意外的 T_FUNCTION ... 第 2 行