html_entity_decode()
Anonymous contributor
Anonymous contributor1 total contribution
Anonymous contributor
Published Nov 12, 2023
Contribute to Docs
‘html_entity_decode()’ is the opposite of ‘htmlentities()’ in that it converts HTML entities in the string to their corresponding characters.
Syntax
html_entity_decode(str, flags, character-set)
- string: - Specifies the string to decode
- flags: - Specifies how to handle quotes and which document type to use.
- character-set: These are optional strings that specify which character-set to use.
Example
The below example takes value for $orig
and assigns it to $a
using htmlentities()
. Then it decodes it using html_entity_decode()
and assigns it to $b
. It then shows values for both $a
and $b
:
<?php$orig = "dog";$a = htmlentities($orig);$b = html_entity_decode($a);echo $a;echo "\n";echo $b;?>
Output
The above example generates the following output:
dogdog
Codebyte Example
This example converts double and single quotes:
All contributors
- Anonymous contributorAnonymous contributor1 total contribution
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.