2016-11-16 69 views
4

我想在我的本地代码中初始化配置项的功能。解析错误:语法错误,意外'['如何解决这个问题?

$cipher->initialize(
     [ 
     'driver'=>'openssl', 
     'key' => $key 
     ] 
    ); 

我越来越 解析错误的错误:语法错误,意想不到的“[”

我可以问如何解决这一问题?

使用PHP 5.3.3

+0

您使用PHP的版本不支持新的数组初始化语法 –

+0

根据您使用的是PHP的版本:'[]'可能会也可能不会。尝试:'$ cipher-> initialize( array( 'driver'=>'openssl', 'key'=> $ key ) );'instead(因为您使用*** PHP 5.3 *** )。 – Poiz

+0

感谢您的答案Poiz。 – Ligthers

回答

10

You are using PHP 5.3. The Array Initialization Construct: [] will not work. Instead, use this approach:

<?php 

     $cipher->initialize(
       array(
       'driver'=>'openssl', 
       'key' => $key 
       ) 
     ); 
4

你的PHP版本不支持[]使用array()代替。

0

不要使用[],用途:

<?php 

     $cipher->initialize(
       array(
       'driver'=>'openssl', 
       'key' => $key 
       ) 
     ); 
相关问题