Sunday 3 June 2018

php - 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:




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

)
);

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...