Skip to content
PHP Ecosystem
Explore

HtmlPurifier

API reference › yii › helpers › HtmlPurifier

classyii\helpers\HtmlPurifier
ExtendsBaseHtmlPurifier
Since2.0
Sourceframework/helpers/HtmlPurifier.php

HtmlPurifier provides an ability to clean up HTML from any harmful code.

Basic usage is the following:

echo HtmlPurifier::process($html);

If you want to configure it:

echo HtmlPurifier::process($html, [
'Attr.EnableID' => true,
]);

For more details please refer to HTMLPurifier documentation.

MethodDescriptionDefined by
process() staticPasses markup through HTMLPurifier making it safe to output to end user.BaseHtmlPurifier
configure() protected staticAllow the extended HtmlPurifier class to set some default config options.BaseHtmlPurifier