Core Function HTMLSpecialCharsDecode
From Sputnik Wiki
HTMLSpecialCharsDecode( <string>, <flags> )
Contents |
Description
Convert special HTML entities back to characters.
Parameters
string
The string being converted.
flags
A bitmask of one or more of the following flags, which specify how to handle quotes, invalid code unit sequences and the used document type.
The default is @ENT_COMPAT.
Available flags constants
Constant Name Description @ENT_COMPAT Will convert double-quotes and leave single-quotes alone. @ENT_QUOTES Will convert both double and single quotes. @ENT_NOQUOTES Will leave both double and single quotes unconverted. @ENT_IGNORE Silently discard invalid code unit sequences instead of returning an empty string. Using this flag is discouraged as it ยป may have security implications. @ENT_SUBSTITUTE Replace invalid code unit sequences with a Unicode Replacement Character U+FFFD (UTF-8) or &#FFFD; (otherwise) instead of returning an empty string. @ENT_DISALLOWED Replace invalid code points for the given document type with a Unicode Replacement Character U+FFFD (UTF-8) or &#FFFD; (otherwise) instead of leaving them as is. This may be useful, for instance, to ensure the well-formedness of XML documents with embedded external content. @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 Value
Returns the decoded string.
Remarks
None.
Example
$new = htmlspecialchars("<a href='test'>Test</a>", @ENT_QUOTES); echo "$new\n"; // <a href='test'>Test</a> $back = htmlspecialcharsdecode("$new", @ENT_QUOTES); echo "$back\n"; // <a href='test'>Test</a>"