HTMLPurifier
Facade that coordinates HTML Purifier's subsystems in order to purify HTML.
- Full name:
\HTMLPurifier
Constants
Constant | Visibility | Type | Value |
---|---|---|---|
VERSION |
public | '4.17.0' |
Properties
version
Version of HTML Purifier.
config
Global configuration object.
filters
Array of extra filter objects to run on HTML, for backwards compatibility.
instance
Single instance of HTML Purifier.
- This property is static.
strategy
generator
context
Resultant context of last run purification.
Is an array of contexts if the last called method was purifyArray().
Methods
__construct
Initializes the purifier.
Parameters:
Parameter | Type | Description |
---|---|---|
$config |
\HTMLPurifier_Config|mixed | Optional HTMLPurifier_Config object for all instances of the purifier, if omitted, a default configuration is supplied (which can be overridden on a per-use basis). The parameter can also be any type that HTMLPurifier_Config::create() supports. |
addFilter
Adds a filter to process the output. First come first serve
Parameters:
Parameter | Type | Description |
---|---|---|
$filter |
\HTMLPurifier_Filter | HTMLPurifier_Filter object |
purify
Filters an HTML snippet/document to be XSS-free and standards-compliant.
Parameters:
Parameter | Type | Description |
---|---|---|
$html |
string | String of HTML to purify |
$config |
\HTMLPurifier_Config | Config object for this operation, if omitted, defaults to the config object specified during this object's construction. The parameter can also be any type that HTMLPurifier_Config::create() supports. |
Return Value:
Purified HTML
purifyArray
Filters an array of HTML snippets
Parameters:
Parameter | Type | Description |
---|---|---|
$array_of_html |
string[] | Array of html snippets |
$config |
\HTMLPurifier_Config | Optional config object for this operation. See HTMLPurifier::purify() for more details. |
Return Value:
Array of purified HTML
instance
Singleton for enforcing just one HTML Purifier in your system
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$prototype |
\HTMLPurifier|\HTMLPurifier_Config | Optional prototype HTMLPurifier instance to overload singleton with, or HTMLPurifier_Config instance to configure the generated version with. |
getInstance
Singleton for enforcing just one HTML Purifier in your system
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$prototype |
\HTMLPurifier|\HTMLPurifier_Config | Optional prototype HTMLPurifier instance to overload singleton with, or HTMLPurifier_Config instance to configure the generated version with. |
Automatically generated on 2025-03-18