Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
解析错误:语法错误,在/ultimate.twitter.feed.php中出现意外的T_函数_Php_Twitter_Twitter Oauth - Fatal编程技术网

解析错误:语法错误,在/ultimate.twitter.feed.php中出现意外的T_函数

解析错误:语法错误,在/ultimate.twitter.feed.php中出现意外的T_函数,php,twitter,twitter-oauth,Php,Twitter,Twitter Oauth,我在服务器上遇到这个错误,但在我的本地机器上同样可以正常工作 以下是在服务器上导致错误的代码行 private function formattedTweet($tweet) { return preg_replace_callback('/{tweet:([a-z-:0-9_]+)}/i', function($match) use($tweet) { $dimensions = explode(':', $match[1]); if(!is

我在服务器上遇到这个错误,但在我的本地机器上同样可以正常工作

以下是在服务器上导致错误的代码行

private function formattedTweet($tweet) {
        return preg_replace_callback('/{tweet:([a-z-:0-9_]+)}/i', function($match) use($tweet) {

        $dimensions = explode(':', $match[1]);

        if(!isset($tweet[$dimensions[0]]))
            return $match[0];

        $replacement = $tweet[$dimensions[0]];

        for($i = 1; $i < count($dimensions); $i++) {
            if(!isset($replacement[$dimensions[$i]]))
                return $match[0];
            else
                $replacement = $replacement[$dimensions[$i]];
        }

        return is_array($replacement) ? $match[0] : $replacement;

    }, self::option('format' . ($tweet['is_retweet'] ? '_retweet' : '')));
}
private函数formattedTweet($tweet){
返回preg_replace_回调('/{tweet:([a-z-:0-9_]+)}/i',函数($match)use($tweet){
$dimensions=分解(“:”,$match[1]);
如果(!isset($tweet[$dimensions[0]]))
返回$match[0];
$replacement=$tweet[$dimensions[0]];
对于($i=1;$i

有什么帮助吗?

很可能您正在尝试在早于5.3的PHP版本上运行此功能,哪个不支持匿名函数
preg\u replace\u callback

错误是否给出了行号?您是否可以编写此错误?您是否检查了PHP版本在本地和服务器上是否相同?您在类中的何处定义了该函数,还是仅定义了一个函数?以下是错误--解析错误:语法错误,第149行出现意外的T_函数您能否升级到PHP5.3?否则,您需要将匿名方法重写为类方法,将
$tweet
变量作为对象属性而不是闭包传递,并使用常规
数组($this,'callbackMethod')
作为回调。