我必须遵循(对我来说是"神秘的")行为:
以下曾经工作(XAMPP,PHP 5.5.15):
$data['item_domain'] = json_decode($this->input->post('item_info'))[0];
但是自从我移动到(LAMP,PHP 5.3.3)它没有更多工作,错误是:
PHP Parse error: syntax error, unexpected '[' ...
作为解决方法,我正在使用这个(...我知道。。。不要打我:-)
$json_decoded = json_decode($this->input->post('item_info'));
$data['item_domain'] ="";
foreach($json_decoded as $items) { $data['item_domain'] = $items; break;}
有人知道吗?
$json_decoded = json_decode($this->input->post('item_info'));
$data['item_domain'] = $json_decoded[0];
您已经降级了 PHP 版本。 该语法仅在 5.4 中可用