Error: syntax error, unexpected 'endforeach' (T_ENDFOREACH)

在跟着CakePHP写Blog这个小代码时,访问这个action:‘http://localhost/cakephp/posts/index’,Chrome报错了,错误如下:

Fatal Error

Error: syntax error, unexpected 'endforeach' (T_ENDFOREACH)
File: D:\Program Files\wamp\www\cakephp\app\View\Posts\index.ctp
Line: 48

php code:

<table>
<tr>
<th>Id</th>
<th>Title</th>
<th>Created</th>
</tr>

<!-- Here is where we loop through our $posts array, printing out post info -->

<?php foreach ($posts as $post); ?>
<tr>
<td><?php echo $post['Post']['id']; ?></td>
<td>
<?php echo $this->Html->link($post['Post']['title'], array('controller' => 'posts', 'action' => 'view', $post['Post']['id'])); ?>
</td>
<td><?php echo $post['Post']['created']; ?></td>
</tr>
<?php endforeach; ?>
<?php unset($post); ?>
</table>

稍稍在网上搜了一下,没细看,后面再仔细对着看时,发现foreach结束时应该是“:” (冒号), 而不是分号(";"), 我没注意写错了。

网上参考链接:

http://stackoverflow.com/questions/20919202/php-syntax-error-unexpected-endforeach-t-endforeach

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值