PHP String htmlspecialchars_decode() Function
The htmlspecialchars_decode() function is an in-built function of PHP, which converts pre-defined HTML entities to characters. It is opposite to the htmlspecialchars() function. HTML entities decoded back to the character will be like-
- & converts as & (ampersand)
- " converts as “ (double-quote)
- ' converts as ‘ (single-quote)
- < converts as < (less than)
- > converts as > (greater than)
The htmlspecialchars_decode() function is used to decode the HTML entities into characters, whereas htmlspecialchars() is used to converts the character in HTML entities.
For Example
HTML output = This is some <i> italic </i> text.
Browser output = This is some italic text
Syntax:
Description
Parameters
string (mandatory): string is the first parameter of this function, to which we will decode. This parameter is mandatory.
flags (optional): flag is the second or last parameter of this function that contains one or more flags constants which states how to handle quotes, and which type of document to be used. By default, they are ENT_COMPAT | ENT_HTML401. Available flags constants are given below in the table:
Constant Name | Description |
---|