Tag Archives: advanced php tutorials
PHP htmlspecialchars_decode Function
PHP htmlspecialchars_decode Function : It converts Some HTML entities to its characters equivalent. This function is opposite of htmlspecialchars() function. We are going to explain this example with example and demo.
PHP htmlspecialchars_decode Function Syntax
It Converts the following entities only –
- & = &(ampersand)
- " = ” (double quote)
- ' = ‘ (single quote)
- < = < (less than)
- > = > (greater than)
Here is syntax for the function htmlspecialchars_decode –
Syntax
htmlspecialchars_decode(string,flags) |
Input Parameters
- string: String to be converted.
- flag:flag is optional . This is basically used to specify how to handle the quotes and which document type use.
Here are following flags available-
- ENT_COMPAT : This is default. Converts only Double Quotes
- ENT_QUOTES : This Converts Both Single and Double Quotes.
- ENT_NOQUOTES : Converts neither Single nor Double Quotes.
- ENT_HTML401 : Handle code as HTML 4.01.
- ENT_XML1 : Handle code as XML 1.
- ENT_XHTML : Handle code as XHTML.
- ENT_HTML5 : Handle code as HTML 5.
Return Values
This function returns the converted string.
PHP htmlspecialchars_decode Function Example-
Let’s understand the above function with example and demo –
PHP htmlspecialchars_decode
$string = " |
The above example will produce the following output-
Html Output
Browser Output
More Example
Let’s have a look over more example and demo here. Here we will explain example with flags.
PHP htmlspecialchars_decode
$string = " |
The above example will produce the following output-