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 .
Related Tutorials
PHP htmlentities() – convert characters to html entities
PHP htmlentities function is used for covert the characters to its HTML entities. This function will automatically identify the characters...
PHP wordwrap function
PHP wordwrap() function is used for wrapping a string to a given number of characters. It will cut the string...
PHP trim() – Remove whitespace from string
PHP trim() function is used for removing the white space or other characters from starting and end of a string....
PHP explode() – split a string by string into array
PHP explode() function is used for split a string by another string into an array.This function is used when we...
strpos() – PHP string first occurance position
PHP strpos function is using for checking the occurrence position of a character or string within a string.It will return...
strlen() – PHP string length function
While our PHP programming , in some cases we need to get the length of a string for processing. strlen()...
PHP fwrite() – writing to a file
PHP fwrite() function is used for writing contents to a file. It write to the file stream pointed to by...
PHP date tutorial
PHP date() function is used for formatting the timestamps in a readable / customized format. date() function will accept an...