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

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页