PHP html_entity_decode – convert to characters

PHP html_entity_decode function is used for covert the HTML entities to its corresponding characters.This function can be used for decode the string maid by htmlentities function.

Its Syntax Will be :
html_entity_decode ( String , Quote Style, Character Set ) ;
First parameter is the string to be converted to characters
Second paramters is an optional will , which will specify how to deal with Single and double quotes
Available quote styles are
ENT_COMPAT Will convert double-quotes and leave single-quotes alone.
ENT_QUOTES Will convert both double and single quotes.
ENT_NOQUOTES Will leave both double and single quotes unconverted.

Third parameter is also optional, where we can specify the character set used in conversion

See a Sample PHP program using html_entity_decode function

<?php
$data="mysqlbrain's tutorials are very <b>good</b>";
$data_1 = htmlentities($data,ENT_QUOTES);
echo html_entity_decode($data_1);
echo "<br>";
echo html_entity_decode($data_1,ENT_QUOTES);
?>

Its output will be :

mysqlbrain’s tutorials are very good
mysqlbrain’s tutorials are very good

We can see that in html_entity_decode with ENT_QUOTES parameter convert the single quote html entity to character .

Share
Share
Share