开发者

Html markup in cakephp's $html->link, eg. $html->link('<span>Hey</span>')?

I have this block of code in a cakephp .ctp file:

<h1>
    <?php echo $this->Html->link('Hello <span>Stack Overflow</span>',
        array('controller'=>'pages', 'action'=>'home'));  ?>
</h1>

But instead of the html being formatted, I'm seeing it literally:

<h1><a href="/rrweb/www/hub/pages/home">
Hello &lt开发者_如何学运维;span&gt;Stack Overflow&lt;/span&gt;</a></h1> 

Any idea's?

Thanks!


You need to disable HTML entity conversion:

echo $this->Html->link(
    'Hello <span>Stack Overflow</span>',
    array('controller'=>'pages', 'action'=>'home'),
    array('escape' => FALSE)
);


or

echo $this->Html->link('Hello', array('controller'=>'pages', 'action'=>'home')).' '.$this->Html->tag('span', $this->Html->link('Stack Overflow', array('controller'=>'pages', 'action'=>'home')), array()); 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜