Ligthers Ligthers - 17 days ago 5
PHP Question

Parse error: syntax error, unexpected '[' How to fix this one?

I'm trying to initialize a function of CI in my native code.

$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

Answer

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
                )
        );
Comments