用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1920|回复: 0
收起左侧

[讨论/交流] 向view传入对象

[复制链接]
发表于 2014-2-27 23:15:11 | 显示全部楼层 |阅读模式
Controller:
~
$news = $this->news_model->get_news($id);  // $news 是一个对象
$news->self = $news; // 测试添加
$this->load->view('news/view', $news);
/*
$news 对象为:
stdClass Object(    [id] => 2    [title] => new    [slug] => new    [text] => This is a test new.    [new] => stdClass Object *RECURSION*)*/
~

View:
~
echo $title; // √
echo $self->id; // √
~
------------------------------------------------------------------------------------





本版积分规则