2015-02-10 73 views
0

严重性:警告 消息:控制器/ 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); 
     } 
+0

什么是错误? – 2015-02-10 17:56:38

+0

从空值创建默认对象 – Keyvin 2015-02-11 14:17:28

+0

如果你喜欢我的回答,请考虑“up-vote” – 2015-02-11 14:25:35

回答

2

小写的“s”在stdClass的:

$response = new stdClass; 

NOT:

$responce = new StdClass; 

了解更多关于PHP对象的位置: http://php.net/manual/de/language.types.object.php

+0

只是一个人抬头。答案是拼写为's',而不是'c'(无论你来自英国还是美国)。 所以最好的答案是'$ response = new StdClass;' – Maximus 2016-02-21 04:09:27

+0

编辑。 TNX .... – 2016-02-22 08:28:37

0

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

$responce = new stdClass(); 

希望这能解决你的错误。

相关问题