意外的T_FUNCTION,但是在哪里? [英] Unexpected T_FUNCTION, but where?

查看:115
本文介绍了意外的T_FUNCTION,但是在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使自己的网站在我的本地计算机上完美运行.但是,迁移到生产环境后,我遇到了意外的T_FUNCTION ..."错误.

I've gotten my site to run perfectly on my local machine. However, migrating to production, I get roadblocked by "Unexpected T_FUNCTION ..." error.

在下面的代码之前,我已经剥离了所有内容,但仍然收到报告第3行的错误.我只是无法弄清楚.

I've stripped everything prior to the following code and still get the error reported for line 3. I just can't figure this out.

<?php
// Auth Check.
$authCheck = function() use ($app) {         <---- Line 3

推荐答案

您将获得:

解析错误:语法错误, 4

因为您使用的PHP版本低于PHP 5.3.0,请升级您的php或尝试使用globals

becasue you are using PHP version less than PHP 5.3.0 upgrade your php or try using globals

PHP 5.3.0+

$app = "Hello Wolrd";
$authCheck = function () use($app) {
    echo $app;
};
$authCheck();

Below PHP 5.3.0

$app = "Hello Wolrd";
$authCheck = function () {
    global $app;
    echo $app;
};
$authCheck();

两者都会输出

  Hello Wolrd

这篇关于意外的T_FUNCTION,但是在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆