我刚开始使用 php 和 cakePhp。我在尝试实现博客教程时遇到了以下错误。
我一直按照教程中的步骤操作,直到这里http://book.cakephp.org/2.0/en/getting-started.html#creating-post-views
错误消息的屏幕截图在这里-
[1]:http: //i.imgur.com/xLvz3.png “top”
[2]:http: //i.imgur.com/cJHPK.png “bottom”
模型/Post.php
<?php
class Post extends AppModel {}
控制器/PostsController.php
<?php
class PostsController extends AppController {
public $helpers = array(’Html’, ’Form’);
public function index() {
$this->set(’posts’, $this->Post->find(’all’));
}
public function view($id = null) {
$this->Post->id = $id;
$this->set(’post’, $this->Post->read());
}}
帖子/index.ctp
<h1>Blog posts</h1>
<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); ?>