开发者

CakePHP Helper Question

开发者 https://www.devze.com 2023-02-02 23:31 出处:网络
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

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

精彩评论

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

关注公众号