PHP html_entity_decode | Decode HTML Entities to Characters

PHP html_entitiy_decode is an inbuilt function in PHP. It converts HTML Entities back to their corresponding characters. It works the opposite of PHP htmlentities Function. In this article, we will discuss the PHP html_entity_decode Function.

Note: To convert characters to HTML entities, use the PHP htmlentities Function.


html_entity_decode ($string, $flags, $encoding)


The PHP html_entity_decode Function accepts three parameters. However, only one parameter is mandatory and the other two are optional. The description of the parameters is as follows:

  • $string: The first parameter specifies the input string to convert.
  • $flags: The second parameter specifies how to handle quotes. It is a combination of two or more flags. You can refer to the list of all the available flags on
  • $encoding: The third parameter specifies the encoding to use while converting. By default, the function uses the default PHP encoding. You can refer to the supported encoding parameters on

Return Value

The PHP html_entity_decode function returns a string after converting all the HTML entities back to their corresponding characters. It uses the UTF-8 as the default encoding.


Input String:

PHP html_entity_decode input string

    echo html_entity_decode($inputString);


Output String:

PHP html_entity_decode output string


In conclusion, we discussed the PHP html_entity_decode Function. You can read more about it on the Official PHP Documentation. Additionally, you can learn about more PHP String Functions on Concatly.

Spread the Knowledge

Leave a Reply

Your email address will not be published. Required fields are marked *