Home > Backend Development > PHP Problem > What are PHP's escape functions for HTML entity characters?

What are PHP's escape functions for HTML entity characters?

coldplay.xixi
Release: 2023-03-05 10:14:02
Original
2570 people have browsed it

PHP针对HTML实体字符的转义函数有:1、【htmlspecialchars()】转义特别的字符为HTML实体;2、【htmlspecialchars_decode()】将实体转成HTML代码。

What are PHP's escape functions for HTML entity characters?

相关学习推荐:php图文教程

PHP针对HTML实体字符的转义函数有:

1、htmlspecialchars()转义特别的字符为HTML实体;

    &#39;&&#39; (ampersand) becomes &#39;&amp;&#39;     &#39;"&#39; (double quote) becomes &#39;&quot;&#39; when ENT_NOQUOTES is not set.     &#39;&#39;&#39; (single quote) becomes &#39;&#039;&#39; only when ENT_QUOTES is set.     &#39;<&#39; (less than) becomes &#39;&lt;&#39;     &#39;>&#39; (greater than) becomes &#39;&gt;&#39;
Copy after login

2、htmlspecialchars_decode()将实体转成HTML代码,函数1的反函数。

3、htmlentities()

这个是全部转换html实体,和htmlspecialchars()区别在于,这个函数是转义全部的字符,而htmlspecialchars()仅仅转义上面限定的5个特殊字符!

4、html_entity_decode() 函数

把 HTML 实体转换为字符。

想了解更多相关学习,敬请关注php培训栏目!

The above is the detailed content of What are PHP's escape functions for HTML entity characters?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template