When the Web editor writes the content of the article to the database, or reads the contents of the database, there are often unresolved problems, a lot of code, which is actually an HTML entity and the corresponding string conversion problem.
Mainly related to Htmlspecialchars (), Htmlentities (), Htmlspecialchars_decode () these functions.
The Htmlspecialchars () function converts some pre-defined characters to HTML entities.
The predefined characters are:
& (and number) becomes &
"(double quotes) becomes"
' (single quote) become '
< (less than) becomes <
> (greater than) becomes >
PHP htmlentities () function
Definition and usage
The Htmlentities () function converts a character to an HTML entity.
Grammar
Htmlentities (String,quotestyle,character-set)
Notice the difference here.
PHP Htmlspecialchars_decode () function
Definition and usage
The Htmlspecialchars_decode () function converts some pre-defined HTML entities to characters.
The HTML entities that will be decoded are:
& Become & (and No.)
"Become" (double quotes)
' Become ' (single quote)
< becomes < (less than)
> Become > (Greater than)
http://www.bkjia.com/PHPjc/477296.html www.bkjia.com true http://www.bkjia.com/PHPjc/477296.html techarticle when the Web editor writes the content of the article to the database, or reads the contents of the database, there are often unresolved problems, a lot of code, which is actually the HTML entity and the corresponding string conversion ...