drbouzlxb92333332 2015-04-13 18:01
浏览 77

在cakephp 3.0中显示Element时出现意外的回声

I was trying to add Element in cakephp template page.

Documentation about Element in cakephp 3.0 says echo must be used.

echo $this->element('helloworld');

I follow documentation, but my website returns this error.

Error: syntax error, unexpected 'echo' (T_ECHO) 

When I don't use echo, it works fine. I tried directly:

$this->element('helloworld');

someone have any explanation about this error ? and where is my error ?

  • 写回答

2条回答 默认 最新

  • duanqinjiao5244 2015-04-13 18:59
    关注

    if you are doing this <?= $this->element('helloworld'); ?> then you don't need echo. However, if you are doing this <?php echo $this->element('helloworld');, then you need echo.

    The difference is whether you are using php's echo short syntax. <?= vs <?php echo and it has nothing to do directly with CakePHP. It is just PHP... More info here: http://php.net/echo

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度