当前位置: 代码迷 >> PHP >> Parse error: syntax error, unexpected T_FUNCTION, expecting ')'该如何解决
  详细解决方案

Parse error: syntax error, unexpected T_FUNCTION, expecting ')'该如何解决

热度:63   发布时间:2016-04-28 17:36:34.0
Parse error: syntax error, unexpected T_FUNCTION, expecting ')'
$c = array_map(function($chicun, $max_chicun) { return $chicun > $max_chicun ? 1 : 0; }, $chicun, $max_chicun);

报错Parse error: syntax error, unexpected T_FUNCTION, expecting ')'
请问什么原因?测试服务器上是没问题的,放在正式用的服务器上就报错
------解决思路----------------------
闭包只在 php 5.3 及以后才有,请检查你的 php 版本

其他的途径
1、定义常规函数用于回调
2、用 create_function 建立回调函数
  相关解决方案