Home >Backend Development >PHP Problem >How to escape html tags in php

How to escape html tags in php

青灯夜游
青灯夜游Original
2021-02-24 18:00:544149browse

In PHP, you can use the htmlentities() function to escape html, which can convert characters into HTML entities, the syntax is "htmlentities(string,flags,character-set,double_encode)". You can also use the html_entity_decode() function in PHP to de-escape html and convert HTML entities into characters.

How to escape html tags in php

The operating environment of this tutorial: windows7 system, PHP8 version, DELL G3 computer

Escape html tags in php

1. The htmlentities() function escapes html

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().

Grammar

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

How to escape html tags in php

How to escape html tags in php

##2. html_entity_decode() function reverses html

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)

How to escape html tags in php

How to escape html tags in php

[Recommended learning: "

PHP Video Tutorial"]

The above is the detailed content of How to escape html tags in php. 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