donglei1616 2014-04-11 16:00
浏览 13

CakePHP正确的语法来打印输出变量

I have a beginners question about CakePHP. I'm trying to print out data I got from database to view but I cannot figure out correct syntax how to do it. I have variable $title in the view.ctp in which there are data I need to print out. I used debug on the $title variable and I got this print out:

array(
    (int) 0 => array(
        'posts' => array(
            'title' => 'The title'
        )
    )
)

But when I try to print out just the title ('The title'), it gives me an error:

Notice (8): Undefined index: posts [APP/View/Posts/view.ctp, line 3]

To print out the title I'm using:

echo h($title['posts']['title']);

What's the correct way to do it? Thanks in advance.

  • 写回答

2条回答 默认 最新

  • dongling0519 2014-04-11 21:00
    关注

    Try:

    echo h($title[0]['posts']['title']);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题