使用 Html 助手在 cake php 中结束 span 标签

发布于 2025-01-08 07:37:48 字数 561 浏览 5 评论 0原文

如何在 cake php 中结束标签

它在 cake 教程中给出,当文本给定 null 时,下面的 span 标签将由 html 帮助器形成。

<?php echo $this->Html->tag('span', null, array('class' => 'welcome'));?>
//Output
<span class="welcome">

但是,这里不知道如何结束 span 标签。如何给它 html 帮助器

<span class="welcome">
    //inner elements
</span>

cake php html 帮助器中是否有任何东西可以关闭任何元素标签,例如

<?php echo $this->Html->tag('span', 'close') ?>

将输出为

</span> . 

How to end the tag in cake php

It is given in cake tutorial the below span tag will be formed by html helper, when text is given null.

<?php echo $this->Html->tag('span', null, array('class' => 'welcome'));?>
//Output
<span class="welcome">

But, here no idea about ending span tag.How can it be given html helper

<span class="welcome">
    //inner elements
</span>

Is there anything in cake php html helper to close any element tags like

<?php echo $this->Html->tag('span', 'close') ?>

will output as

</span> . 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千笙结 2025-01-15 07:37:48

您还可以这样做:

<?php
echo $html->tag("span", null);
... whatever ...
echo $html->tag("/span", null);
?>

You can also do this:

<?php
echo $html->tag("span", null);
... whatever ...
echo $html->tag("/span", null);
?>
匿名。 2025-01-15 07:37:48

调用 tag 方法时,您必须为第二个参数提供空字符串 "",而不是 null。否则,它只是根据 打印开始标记API 文档

You have to provide an empty string "", instead of null, for the second parameter when calling the tag method. Otherwise, it just prints the start tag according to the API docs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文