繁体   English   中英

htmlentities与其中的字符串htmlentities究竟有什么关系?

[英]What does htmlentities exactly do with string htmlentities in it?

var_dump(htmlentities("<space>")); 

返回string(21) "<space>",

21个字符吧?

实际上,它返回了其他内容:

<? var_dump(htmlentities("&lt;space&gt;")); ?>
string(21) "&amp;lt;space&amp;gt;"

您看到的是转义字符串:)的未转义版本。

有空格或特殊格式。

"&amp;lt;space&amp;gt;" = 21个字符。

因为它会将“&”号转换为它的HTML实体。

& => &amp;

因此,您实际上以以下字符串结尾:

&amp;lt;space&amp;gt;

这是21个字符。

您可以在浏览器上查看源,以查看上面的确切字符串。 如果您没有查看源,则浏览器会转换&amp; 回到& ,这就是为什么您只看到&lt;space&gt;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM