【问题标题】:cakephp: undefined variable error when passing variable from controller to viewcakephp:将变量从控制器传递到视图时出现未定义变量错误
【发布时间】:2011-09-21 06:55:59
【问题描述】:

当我在注册页面点击提交时,我收到"Notice (8): Undefined variable: id [APP\views\merry_parents\report_card.ctp".

我只是想使用$this->set($id,$this->data['MerryParent']['id']);$this->data['MerryParent']['id']merry_parents_controller 传递到report_card 视图

谁能告诉我我做错了什么?提前致谢。

以下是我的代码:

//report_card.ctp

 <?php
     echo 'HALLO';
     echo $id;
 ?>

【问题讨论】:

    标签: cakephp variables view controller


    【解决方案1】:

    用途:

    $this->set('id', $this->data['MerryParent']['id']);
    

    第一个参数是所需的名称​​作为字符串,而不是作为变量。

    【讨论】:

      猜你喜欢
      • 2017-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-21
      • 1970-01-01
      • 2019-08-30
      • 1970-01-01
      相关资源
      最近更新 更多