开发者

CakePHP Helper Question

What is difference between this:

$h开发者_如何学编程tml->link

and

$this->Html>link

The first one works fine, but the second one always throws errors, but is used often in documentation over the first one. What is the difference?


Use the first syntax to refer to the HTML helper in a view (like you normally would).

The second syntax is used to refer to the HTML helper in another helper. Example.


The second syntax is newer and was introduced with CakePHP 1.3.0: http://book.cakephp.org/view/1572/New-features-in-CakePHP-1-3#View-Helpers-1574. And you can use this syntax not only in other helpers as mentioned by kizzx2, but also in your views.

Getting errors with this syntax means you are using an old CakePHP version.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜