php 解析错误:语法错误,意外的 '[' 如何解决这个问题?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40624805/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Parse error: syntax error, unexpected '[' How to fix this one?
提问by Ligthers
I'm trying to initialize a function of CI in my native code.
我正在尝试在我的本机代码中初始化 CI 的函数。
$cipher->initialize(
[
'driver'=>'openssl',
'key' => $key
]
);
I'm getting an error of Parse error: syntax error, unexpected '['
我收到 解析错误的错误:语法错误,意外的 '['
Can I ask how to fix this?
我能问一下如何解决这个问题吗?
Using Php 5.3.3
使用 PHP 5.3.3
回答by Poiz
You are using PHP 5.3. The Array Initialization Construct:
[]
will not work. Instead, use this approach:
您正在使用 PHP 5.3。数组初始化构造:
[]
将不起作用。相反,使用这种方法:
<?php
$cipher->initialize(
array(
'driver'=>'openssl',
'key' => $key
)
);
回答by Muhammed Imran Hussain
Your PHP version doesn't support []
use array()
instead.
您的 PHP 版本不支持[]
使用array()
。
回答by Doruk Ayar
Don't use []
, Use:
不要使用[]
,使用:
<?php
$cipher->initialize(
array(
'driver'=>'openssl',
'key' => $key
)
);