htmlentities 不适合我
我正在尝试对某些文本中的 html 字符进行编码以在电子邮件中发送。 我使用了这个:htmlentities,但它对我不起作用。
我尝试了这个例子:
$str = "A 'quote' is <b>bold</b>";
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str);
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str, ENT_QUOTES);
来自: http://www.php.net/manual/ fr/function.htmlentities.php
你能解释一下为什么它不起作用吗?
I am trying to encode html characters in some text to send in an email.
I used this: htmlentities, but it didn't work for me.
I tried this example :
$str = "A 'quote' is <b>bold</b>";
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str);
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str, ENT_QUOTES);
from: http://www.php.net/manual/fr/function.htmlentities.php
Can you please, explain why it didn't work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
htmlentities 用于转义 HTML 中有意义的字符,例如 <和>。如果您想在网页上显示这些字符而不破坏 HTML,那么它非常有用。它并不意味着在电子邮件中显示 HTML。
htmlentities is used to escape characters meaningful in HTML, like < and >. It is useful if you want to display those characters on a webpage without disrupting the HTML. Its is not meant to display HTML in an email.