cakephp 的 $html-> 链接中的 HTML 标记,例如.$html->link('<span>嘿</span>')? [英] Html markup in cakephp's $html->link, eg. $html->link('<span>Hey</span>')?

查看:21
本文介绍了cakephp 的 $html-> 链接中的 HTML 标记,例如.$html->link('<span>嘿</span>')?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 cakephp .ctp 文件中有这段代码:

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>

但是我看到的不是 html 格式,而是字面意思:

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> 

有什么想法吗?

谢谢!

推荐答案

您需要禁用 HTML 实体转换:

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

这篇关于cakephp 的 $html-> 链接中的 HTML 标记,例如.$html->link('&lt;span&gt;嘿&lt;/span&gt;')?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆