Home  >  Article  >  Backend Development  >  PHP implements escaping of html tags

PHP implements escaping of html tags

藏色散人
藏色散人Original
2020-07-14 09:09:227017browse

In PHP, you can use the "htmlentities" function to escape html tags. This function is used to convert characters into HTML entities. Its syntax is "htmlentities(string,flags,character-set,double_encode)".

PHP implements escaping of html tags

PHP Html tag escaping and anti-escaping

1. htmlentities() function to escape html

2. The html_entity_decode() function reverses html

1: The htmlentities() function converts characters into HTML entities.

Tip: To convert HTML entities back to characters, use the html_entity_decode() function.

Tip: Please use the get_html_translation_table() function to return the translation table used by htmlentities().

Syntax

htmlentities(string,flags,character-set,double_encode)

2: The html_entity_decode() function converts HTML entities into characters.

html_entity_decode() function is the inverse function of htmlentities() function.

Grammar

html_entity_decode(string,flags,character-set)

For more related knowledge, please visit PHP Chinese website!

The above is the detailed content of PHP implements escaping of html tags. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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