Short config setup

13 views
Skip to first unread message

Craig Francis

unread,
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();
 $config
->set('Core.Encoding', 'UTF-8');
 $config
->set('HTML.Doctype', 'XHTML 1.0 Strict');
 $config
->set('Cache.DefinitionImpl', null);
 $purifier
= 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

unread,
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.

Edward

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