8

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

3
  • You're using a version of PHP that does not support new array initialization syntax Commented Nov 16, 2016 at 5:41
  • Depending on the Version of PHP you are using: [] may or may not work. Try: $cipher->initialize( array( 'driver'=>'openssl', 'key' => $key ) ); instead (since you are using PHP 5.3). Commented Nov 16, 2016 at 5:41
  • Thanks for the answer Poiz. Commented Nov 16, 2016 at 5:43

3 Answers 3

27

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
                )
        );
Sign up to request clarification or add additional context in comments.

Comments

8

Your PHP version doesn't support [] use array() instead.

Comments

1

Don't use [], Use:

 <?php

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.