There is issue in session. This is my array.
print_r($this->session->userdata("user_data"));
Array
(
[useremail] => myid@gmail.com
[user_id] => 1
[is_login] => 1
)
I want to get the useremail . so I am writing this code.
print_r($this->session->userdata("user_data")['useremail']);
It gives the error . Parse error: syntax error, unexpected '['
If I am writing the code like this :
$dataval = $this->session->userdata("user_data");
print_r($dataval['useremail']);
Then it it working fine .
Please help me what is issue ?
It is because you (probably) moved from newer php version (5.4+) to older version (5.2). Accessing array items directly by calling function name is only available on php 5.4 and newer: array dereferencing .
Only solution is to use temporary variable (like your $dataval
). Or you can switch to newere php version, if the bluehost allows it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.