PHP htmlspecialchars_decode() Function converts the predefined HTML entities back to characters.
A predefined HTML entities are given as below.
- & will be converted to & (ampersand).
- " will be converted to " (double quote).
- ' will be converted to ' (single quote).
- < will be converted to < (less than).
- > will be converted to > (greater than).
Syntax :
htmlspecialchars_decode(string,flags)
Parameter,
string : Required. Input the string to decode.
flags : Optional. It specifies how to handle quotes and which document type to use. The default is ENT_COMPAT | ENT_HTML401.
Available flags constants are given as below.
- ENT_COMPAT- It will convert double-quotes and leave single-quotes alone.
- ENT_QUOTES - It will convert both double and single quotes.
- ENT_NOQUOTES- It will leave both double and single quotes unconverted.
- ENT_HTML401 - It handles code as HTML 4.01.
- ENT_XML1 - It handles code as XML 1.
- ENT_XHTML - It handles code as XHTML.
- ENT_HTML5 - It handles code as HTML 5.
A htmlspecialchars_decode() returns decoded string.
Let's see below example to understand php htmlspecialchars_decode() Function in details.
Comments