【发布时间】:2015-02-10 17:51:01
【问题描述】:
严重性:警告 消息:从空值创建默认对象 文件名:控制器/person.php 行号:133
function update($id)
{
$responce = new StdClass;
$this->_set_rules();
$person = $this->Person_model->get_by_id($id)->row();
error in this line i try to figure it ot
$this->form_data->id = $id;
$this->form_data->name = $person->name;
$this->form_data->gender = strtoupper($person->gender);
$this->form_data->dob = date('d-m-Y',strtotime($person->dob));
$data['title'] = 'Update person';
$data['message'] = '';
$data['action'] = site_url('person/updatePerson');
$data['link_back'] = anchor('person/index/','Back to list of persons',array('class'=>'back'));
// load view
$this->load->view('personEdit', $data);
}
【问题讨论】:
-
从空值创建默认对象
-
如果您喜欢我的回答,请考虑“投票”
-
form_data 来自哪里?我看到您正在从 Person_model 获取数据并将结果行保存到变量 $person...但我看不到您在哪里声明 form_data(至少在此函数中)
标签: codeigniter stdclass