问题描述
我在第一次尝试CakePHP时收到此错误:
I am getting this error on my first attempt of CakePHP:
我有版本2.0-alpha,我有错误的版本或什么改变了。看起来找不到html助手。
I have version 2.0-alpha, have I got the wrong version or what has changed again. Seems it can't find the html helper.
更多信息请求:
这里是索引。 ctp档案
Here is the index.ctp file
<?php foreach ($posts as $post): ?>
<?php echo $post['Post']['id']; ?>
<?php
##line 13 here
echo $html->link($post['Post']['title'], array('controller' => 'posts', 'action' => 'view', $post['Post']['id']));
?>
<?php echo $post['Post']['created']; ?>
<?php endforeach; ?>
数据肯定会通过,但我得到的错误是第13行:
The data is definitely coming through but the error I get is this on line 13:
我很新,希望这有帮助。
I'm quite new I hope this helps.
更新5小时后会疯狂
感谢各位排序,任何人都有这个问题在主网站的教程是一个老,没有人做了努力更新它!! ... in the index.ctp example
Thanks guys it's sorted incase anybody has this problem the tutorial on the main site is an old one and nobody has made the effort to update it!! ...in the index.ctp example replace
$html->link(...
与
$this->Html->link(...
推荐答案
从cakephp的手册,在CakePHP 2.0中, $ html
应该是 $ this-> Html
From the manual of cakephp, it seems that $html
should be $this->Html
in CakePHP 2.0.
这篇关于在CakePHP 2.0中使用Html Helper时未定义的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!