Php htmlspecialchars decode
From w3cyberlearnings
Contents |
PHP function htmlspecialchars_decode
This function converts special HTML entities back to character.
Syntax htmlspecialchars_decode
- string: string input contains HTML special entities.
htmlspecialchars_decode(string);
Return
Return encode string.
HTML Entities
- <: < (less than)
- >: > (greater than)
- &: & (ampersand)
- ": " (double quote)
- ': ' (single quote)
Example 1
<?php $str = 'a > than b, but 'aa' < than "ab"'; echo htmlspecialchars_decode($str); ?>
Output
a > than b, but 'aa' < than "ab"
Example 2: Do not decode a single quote
<?php $str = 'a > than b, but 'aa' < than "ab"'; echo htmlspecialchars_decode($str,ENT_COMPAT); ?>
Output
a > than b, but 'aa' < than "ab" //HTML View Source a > than b, but 'aa&#amp;039; < than "ab"