Introduction
In this article I describe the PHP string functions html_entity_decode, htmlentities and htmlspecialchars_decode. To learn some other math functions, go to:
- String Functions in PHP: Part1
- String Functions in PHP:Part2
- String Functions in PHP:Part3
- String Functions in PHP:Part4
- String Functions in PHP:Part5
PHP html_entity_decode() Function
The PHP string html_entity_decode function converts all HTML entities to their applicable characters.
Syntax
| html_entity_decode(string, quotestyle,character-set) |
Parameter in html_entity_decode Function
The parameters of the html_entity_decode function are:
| Parameter | Description |
| string | It specifies the input string. |
| quotestyle | It specifies how to decode single or double quotes. The possible quote styles are:
|
| character-set | It specifies a string that specifies what character set is used. |
Example
An example of the html_entity_decode function is:
<?php
$str = "We are learning <b>PHP</b> at <a href='http://www.c-sharpcorner.com/1/279/php.aspx'>C-sharpCorner.com</a>";
echo html_entity_decode($str);
?>
Output
PHP htmlentities() Function
The PHP string htmlentities function converts all applicable characters to HTML entities.
Syntax
| htmlentities (string, quotestyle,character-set) |
Parameter in htmlentities Function
The parameters of the htmlentities function are:
| Parameter | Description |
| string | It specifies the string to convert. |
| quotestyle | It specifies how to encode single or double quotes. The possible quote styles are:
|
| character-set | It specifies a string that specifies what character set is used. |
Example
An example of the htmlentities function is:
<?php



Join the conversation! Your thoughts help the community grow.