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 PHP.net.
- $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 PHP.net.
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.
<?php echo html_entity_decode($inputString); ?>
Vishesh is currently working as an Intermediate Software Engineer with Orion Health, New Zealand. He graduated with a Masters in Information Technology from the University of Auckland in 2021. With more than 4 years of work experience, his expertise includes Java, Python, Machine Learning, PHP, Databases, Design and Architecture.