PHP html_entity_decode() Function
The html_entity_decode()
function converts HTML entities to characters. This feature is especially useful when displaying HTML entities as plain text or converting them to their original characters. html_entity_decode function is the inverse of htmlentities().
Syntax
html_entity_decode(string,flags,character-set)
Parameter | Description |
---|---|
string | (Required) Specify the string to decode. |
flags | (Optional) Specify how offers are processed and what type of document to use.
|
character-set | (Optional) A string indicating which character set to use.
|
Example
<?php $txt = '<a href="https://www.vrsofttech.com/">VR SOFT TECH</a'; echo html_entity_decode($txt); ?>
Output
VR SOFT TECH
Convert HTML entities to characters using the flags parameter
Example
<?php $txt = ""Any sufficiently advanced technology is equivalent to magic.""."<br>"; echo html_entity_decode($txt,ENT_COMPAT); echo html_entity_decode($txt,ENT_QUOTES); echo html_entity_decode($txt,ENT_NOQUOTES); ?>
Output
"Any sufficiently advanced technology is equivalent to magic." "Any sufficiently advanced technology is equivalent to magic." "Any sufficiently advanced technology is equivalent to magic."