PHP意外的'[' [英] PHP unexpected '['

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

问题描述

我认为这是服务器配置错误,而不是php语法错误. 运行Apache/2.2.20(Ubuntu)和PHP版本5.3.10-1ubuntu3.7

I think it's a server configuration error and not a php syntax error. running Apache/2.2.20 (Ubuntu) and PHP Version 5.3.10-1ubuntu3.7

错误:

PHP解析错误:语法错误,第30行在/home/thomas/Documents/myimouto/config/application.php中出现意外的[[]

PHP Parse error: syntax error, unexpected '[' in /home/thomas/Documents/myimouto/config/application.php on line 30

这是代码

$config->load_files = [
        'app_functions.php',
        'Moebooru/Resizer.php',
        'dtext.php'
    ];

$config->safe_ips = [
        '127.0.0.1',
    '192.168.1.###'
    ];

推荐答案

请首先检查您的PHP版本. array 声明[]的简写形式仅在PHP 5.4版本中引入(如果没有记错的话).以前的版本仅支持()分隔符.

Check your PHP version first. The short hand form for the array declaration [] was only introduced in PHP's version of 5.4 (if am not mistaken). The previous versions only supported the () delimiters.

所以,我建议您尝试将该行更改为:

So, I suggest you try changing that line to:

$config->safe_ips = array(
     '127.0.0.1',
    '192.168.1.###'
    );

或更妙的是,更新为 PHP > 5.4 是的.

or better yet, update to PHP > 5.4Yeah..

这篇关于PHP意外的'['的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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