html特殊字符

发布于 2024-09-04 11:17:42 字数 188 浏览 5 评论 0原文

如果我在插入/编辑视图上使用表单提交像我的字符串这样的数据,在列表视图上我会得到斜体的字符串(就像这里)。

我怎样才能避免这种情况,并在所有表单上都有我的字符串(带有可见的所有html标签)?

即,它看起来像这样: my string

提前致谢!

if i submit data like my string using form on insert/edit view, on a list view i'll get my string as italic (like here).

how can i avoid that, and to have my string (with visible all html tags) on all forms?

i.e. so it appears like this: <i>my string</i>

thanks in advance!

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

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

发布评论

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

评论(2

把昨日还给我 2024-09-11 11:17:42

因此,您会问,当您呈现数据库中存在的结果时,如何转义视图上的 HTML 代码……是这样吗?

假设这就是您所要求的,在您看来,您可以简单地包装数据库字段输出

<?php

foreach ( $rows as $row ) { 
    echo $html->tag("p",htmlentities($row['Model']['field']));
}
// or more simply
foreach ( $rows as $row ) { 
    echo htmlentities($row['Model']['field']).'<br/>';
}

?>

So you're asking how you can escape the HTML code on your views when you render the results as they exist in the database... is that right?

Assuming that is what you're asking, in your view, you could simply wrap the DB field output

<?php

foreach ( $rows as $row ) { 
    echo $html->tag("p",htmlentities($row['Model']['field']));
}
// or more simply
foreach ( $rows as $row ) { 
    echo htmlentities($row['Model']['field']).'<br/>';
}

?>
十六岁半 2024-09-11 11:17:42

也许选项 'escape'=>true 会很有用,例如:

$html->tag('p', $text, array('escape'=>true));

Maybe the option 'escape'=>true will be useful, like in:

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