【发布时间】:2011-09-18 17:09:31
【问题描述】:
我有以下代码:
$file_check_method_func = function($n) {
$n = absint($n);
if(1 !== $n) { $n = 0; }
return $n;
};
$valid['file_check_method'] = array_map($file_check_method_func, $input['file_check_method']);
这适用于我的 PHP 5.3.5 安装,但是当我在 PHP 5.2.15 安装上运行此代码时,我得到:
Parse error: syntax error, unexpected T_FUNCTION in /home/xxxx/public_html/xxxx/xxxxxxx/wp-content/plugins/wordpress-file-monitor-plus/classes/wpfmp.settings.class.php on line 220
第 220 行是上述代码的第一行。
所以我的问题是,我的代码中是否有错误的内容会导致此错误?如果不是,是因为 PHP 5.2.15 中的错误或不支持的功能?如果是,那么我该如何编写上述代码以免产生错误?
以上代码在一个类的函数中。
【问题讨论】:
标签: syntax-error php anonymous-function