How to configure ob_tidyhandler dynamically?
===

The PHP tidy extension has a function [`ob_tidyhandler`<sup>*Docs*</sup>](http://php.net/ob_tidyhandler) that works with [PHP output buffering<sup>*Docs*</sup>](http://php.net/manual/book.outcontrol.php) as a callback, e.g.:

    ob_start('ob_tidyhandler');

I know that Tidy has [a lot of configuration settings<sup>*Docs*</sup>](http://tidy.sourceforge.net/docs/quickref.html), however I am hitting a road block to setup default configuration options for that output buffer callback.

Most of Tidy's PHP function refer to a tidy document or object, however with the output buffering that one is not accessible.

There is a configuration setting [`tidy.default_config`](http://php.net/manual/tidy.configuration.php#ini.tidy.default-config), however that is not change-able at runtime, so it is not very dynamic.

Does anybody know if configuring the callback dynamically is possible at all? I remember I wrote a callback my own, collected all output and repaired it with a call to [`tidy_repair_string`<sup>*Docs*</sup>](http://php.net/tidy_repair_string ) which accepts configuration as an array. But I thought it would be nice to not need to do that and just pass the configuration along for the output buffer.