codeigniter,错误消息:从空值创建默认对象

时间:2015-02-10 17:51:02

标签: codeigniter stdclass

严重性:警告 消息:从空值创建默认对象 文件名:controllers / 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);
        }

2 个答案:

答案 0 :(得分:2)

stdClass中的小写“s”:

$response = new stdClass;

NOT:

$responce = new StdClass;

在此处了解有关PHP对象的更多信息: http://php.net/manual/de/language.types.object.php

答案 1 :(得分:0)

您需要创建数据对象,如下所示。

$responce = new stdClass();

希望这能解决您的错误。