doubi2145 2017-02-02 16:43
浏览 40

试图获取为foreach()提供的非对象CodeIgniter和Invalid参数的属性

php version 5.3.1 with codeigniter 2.0.2

help me, i have errors like this :

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object and Invalid argument supplied for foreach()

Filename: controllers/login.php

Line Number: 20

Controller

parent::__construct();
    $this->load->model('option_m');
    $option = $this->option_m->get_by(array('nama_opsi' => 'store_option'));
    foreach (unserialize($option->value_opsi) as $key => $val) {
        $this->data->$key = $val;
    }
    $this->template->use_asset()->set_judul('Form Login')->set_css('login');

    $this->data->metadata = $this->template->get_metadata();
    $this->data->judul = $this->template->get_judul();
}

in the sublime text, line number 20 is, but im not sure:

foreach (unserialize($option->value_opsi) as $key => $val) {
$this->data->$key = $val;
  • 写回答

2条回答 默认 最新

  • dongtong5242 2017-02-02 18:09
    关注

    Try storing unserialize($option->value_opsi) in an intermediate variable and print it out. I'm betting that's not an array format that foreach can accept.

    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程