PHP htmlspecialchars_decode
The PHP htmlspecialchars_decode function can convert special HTML entity symbols back to normal HTML symbols. It is usually used to process special symbols converted by htmlspecialchars . For example, after the data is retrieved from MySQL and contains HTML entity symbols, it must be converted back to normal symbols with htmlspecialchars_decode. , Can be output on the web page, to avoid readers thinking that the data they see is garbled, this function can only be used with PHP 5.1.0 or later.
PHP htmlspecialchars_decode basic syntax
string htmlspecialchars_decode( $string , $quote_flags )
The first parameter $ string within parentheses htmlspecialchars_decode function is to convert the string , required items, and the second parameter is set to $ quote_flags quoted parameters, optional items can not fill, the default value ENT_COMPAT means that only double quotation marks will be converted. If set to ENT_QUOTES, single quotation marks or double quotation marks can be converted, and set to ENT_NOQUOTES, no matter whether it is single quotation marks or double quotation marks, it will not be converted.
PHP htmlspecialchars_decode reference example
$string_1 = htmlspecialchars_decode("Connect symbol&; greater than>; less than<; single quote'; double quote" ", ENT_COMPAT);
echo $string_1.'<br>';
$string_2 = htmlspecialchars_decode("connection symbol&; greater than>; less than <; single quotes'; double quotes" ", ENT_QUOTES);
echo $string_2.'<br>';
$string_3 = htmlspecialchars_decode("Connect Symbols &; greater than>; less than <; single quotes'; double quotes" ", ENT_NOQUOTES);
echo $string_3.'<br>';
?>
connection symbol &; greater than>; less than <; single quotation mark'; double quotation mark "
connection symbol &; greater than>; less than <; single quotation mark'; double quotation mark "
Post a Comment
0 Comments