【问题标题】:How to add span tag in CakePHP HtmlHelper?如何在 CakePHP HtmlHelper 中添加 span 标签?
【发布时间】:2014-11-18 07:06:41
【问题描述】:

我有一个 html 标签 -

   <li>
       <a class="" href="http://www.sitename.com/logout">
          <i class="icon-key"></i>
          <span>Logout</span>
       </a>
  </li>

我想在CakePHP Html格式的html上面写-

我的代码-

<li>
    <?php echo $this->Html->link(
        $this->Html->tag('i', 'Logout', array('class' => 'icon-key')),
        '/logout',
        array('escape'=>false));
    ?>
</li>

我的代码运行良好,但 span 标记未显示。如何在上面的html中添加span标签?

谢谢

闲聊

【问题讨论】:

    标签: html cakephp


    【解决方案1】:

    考虑以下代码:简单地使用 cakephp 的两个标签并使用 . 连接它们

    <?php echo $this->Html->link(
            $this->Html->tag('i', '', array('class' => 'icon-key')).$this->Html->tag('span', 'Logout'),
            '/logout',
            array('escape'=>false));
        ?>
    

    给出输出:

    <a href="/savaganza/logout">
      <i class="icon-key">
      </i>
      <span>Logout</span>
    </a>
    

    【讨论】:

    • 我需要跨越i标签
    【解决方案2】:

    你也可以这样做:

     <li>
        <?php echo $this->Html->link(
            $this->Html->tag('i', '<span>Logout</span>', array('class' => 'icon-key')),
            '/logout',
            array('escape'=>false));
        ?>
    </li>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-29
      • 2012-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多