html,php -Escape'<'和'>'符号回声

发布于 2025-01-30 12:29:23 字数 130 浏览 3 评论 0 原文

我想打印以下文本:

echo "<label> AAAAA";

但是它只是将“ AAAAA”显示为输出。

我怎么能逃脱'&lt;'和'&gt;'象征。

I want to print following text as it is:

echo "<label> AAAAA";

But it is just showing 'AAAAA' as output.

How can I escape '<' and '>' symbol.

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

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

发布评论

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

评论(8

2025-02-06 12:29:23

使用 htmlspecialchars

<?php
    echo htmlspecialchars("abc & < >");
?>

Use htmlspecialchars.

<?php
    echo htmlspecialchars("abc & < >");
?>
2025-02-06 12:29:23
<?php
    $string = "<label> AAAAA"; //whatever you want
    echo htmlspecialchars($string);
?>

corrence htmlspecialchars

<?php
    $string = "<label> AAAAA"; //whatever you want
    echo htmlspecialchars($string);
?>

refrence htmlspecialchars

谈场末日恋爱 2025-02-06 12:29:23
echo htmlentities("<label> AAAAA");
echo htmlentities("<label> AAAAA");
风情万种。 2025-02-06 12:29:23

使用 htmlentities() 纯文本字符串。

<?php
echo htmlentities("<label> AAAAA");
?>

Use the htmlentities() function to convert into a plain text string.

<?php
echo htmlentities("<label> AAAAA");
?>
情魔剑神 2025-02-06 12:29:23

check this http://php.net/manual/en/function.htmlentities.php, and this is code -

echo htmlentities ("<label> AAAAA");
豆芽 2025-02-06 12:29:23

您应该逃脱HTML的特殊字符。

echo“&amp; lt; label&amp; gt; aaaa”

You should escape your especial characters for HTML.

echo "<label> AAAA"

http://www.w3schools.com/tags/ref_entities.asp

凉月流沐 2025-02-06 12:29:23
echo "<label> AAAAA";
echo "<label> AAAAA";
晨曦÷微暖 2025-02-06 12:29:23

使用HTML实体:&amp; lt; 用于&lt; and &amp; gt; for &gt; 。可以使用 htmlspecialchars 函数来实现: http://php.net/htmlspecialchars

在此处阅读有关html实体的更多信息: http://www.santagata.us/characters/characterities/characterentities.html < /a>

Use HTML entities: < for < and > for >. Could be achieved using htmlspecialchars function: http://php.net/htmlspecialchars.

Read more about HTML entities here: http://www.santagata.us/characters/CharacterEntities.html

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