dswe30290 2013-11-16 19:13
浏览 83
已采纳

第22行/home1/gcc/public_html/university/core/init.php中的解析错误:语法错误,意外T_FUNCTION,期待')'[重复]

Run the code in local host wamp, but when i uploaded to the server i got this error. Below is my code

<?php
session_start();

$GLOBALS['config'] = array(
    'mysql' => array(
        'host' => 'localhost',
        'username' => 'root',
        'password' => '',
        'db'=> 'database name'
    ),
    'remember' => array(
        'cookie_name' => 'hash',
        'cookie_expiry' => 604800
    ),
    'session' => array(
        'session_name' => 'user',
        'token_name' => 'token',
        'secure' => rand(1000, 9999)
    )
);

spl_autoload_register(function($class) {            // error here
    require_once 'classes/' .$class. '.php';
});
</div>
  • 写回答

2条回答 默认 最新

  • duaiwo9093 2013-11-16 19:18
    关注

    It seems because you are running on an old PHP version (older than PHP 5.3), anonymous function are seen as syntax errors. PHP implements callbacks as string. You can define the function normally, and pass a name of the function instead.

    function custom_autoloader($class) {
        // your code..
    }
    
    spl_autoload_register('custom_autoloader');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?