Short config setup

Skip to first unread message

Craig Francis

Nov 26, 2018, 1:40:56 PM11/26/18
to htmlpurifier
At the moment, all of the documentation uses the "HTMLPurifier_Config" object to configure "HTMLPurifier":

 $config = HTMLPurifier_Config::createDefault();
->set('Core.Encoding', 'UTF-8');
->set('HTML.Doctype', 'XHTML 1.0 Strict');
->set('Cache.DefinitionImpl', null);
= new HTMLPurifier($config);

But "HTMLPurifier" can also accepts a simple array:

 $purifier = new HTMLPurifier([
'Core.Encoding'        => 'UTF-8',
'HTML.Doctype'         => 'XHTML 1.0 Strict',
'Cache.DefinitionImpl' => null,

Does this second approach cause any problems?

The HTMLPurifier_Config::create() method does include an is_array() check, and uses $ret->loadArray($config).

I ask, because I've got a very simple/basic autoloader, and it works much better by starting with the "HTMLPurifier" class.

Edward Z. Yang

Nov 26, 2018, 9:14:02 PM11/26/18
to Craig Francis, htmlpurifier
I don't think there is anything problematic about using this form. Use
the one that works best for you.


Excerpts from Craig Francis's message of 2018-11-26 10:40:56 -0800:
Reply all
Reply to author
0 new messages