The html_entity_decode Function
The html_entity_decode
function converts
HTML entities to their corresponding characters.
See examples for better understanding.
Syntax
html_entity_decode(string $string, int $flags = ENT_COMPAT, ?string $encoding = null): string
Example
Let's convert a string with tags:
<?php
$str = '<b>text</b>';
$res = html_entity_decode($str);
echo $res;
?>
Code execution result:
'<b>text</b>'
Example
Let's convert a string with an ampersand:
<?php
$str = 'test: &';
$res = html_entity_decode($str);
echo $res;
?>
Code execution result:
'test: &'
See Also
-
the
htmlentities
function,
which performs the reverse operation -
the
htmlspecialchars
function,
which performs a similar reverse operation