PHP html_entity_decode() Function Example

PHP Script:

<?php
$str = “A ‘PHPTUTORS’ is &lt;b&gt;Awsome&lt;/b&gt;”;
echo html_entity_decode($str);
echo “< br/ >”;
echo html_entity_decode($str, ENT_QUOTES);
?>

Output:

A ‘PHPTUTORS’ is Awsome< br/ >A ‘PHPTUTORS’ is Awsome

Description:

html_entity_decode() function Convert all HTML entities to their applicable characters. In above example the source of the output will look like

[

A 'PHPTUTORS' is <b>Awsome</b>< br/ >A 'PHPTUTORS' is <b>Awsome</b>

]

html_entity_decode() function parameters:

1- string : The input string value.
2- int : Bitmask  for specifying criteria of encodings. [Optional] Default value : [ int $flags = ENT_COMPAT | ENT_HTML401 ]
3- string : Defines encoding used in conversion.  [Optional] Default value : [ string $encoding = ‘UTF-8’ ]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s