我得到未定义的索引:id [APP\controllers\merry_parents_controller.php,第 31 行]代码
debug($this->data['MerryParent']);
echo 'id: '.$this->data['MerryParent']['id'];
MerryParentsController::login() - APP\controllers\merry_parents_controller.php, line 31
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 204
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171
[main] - APP\webroot\index.php, line 83
我的代码:
merry_parents_controller.php
if ($this->Auth->user()){
//debug($this->Auth->user());
$this->data['MerryParent']=$this->Auth->user();
debug($this->data['MerryParent']);
echo 'id: '.$this->data['MerryParent']['id'];
对于调试($this->data['MerryParent']),记录显示正常:
Array
(
[MerryParent] => Array
(
[id] => 2
[initial] => Ms
[username] => hong
[email] => hong7@yahoo.com
[password2] => hong7
[landline] =>
[mobile] => 293472389472
[address] => dsaflkjasdlfk
[state_id] => 5
[city_id] => 62
[postal_code] => 825729
[created] => 2011-08-02 10:29:59
[modified] => 2011-09-26 06:42:27
)
)
但是当我尝试 echo 'id: '.$this->data['MerryParent']['id'];
我收到通知 8:未定义的索引错误。我不知道有什么问题。有人可以帮帮我吗?