too long

I have one 3 party script that catches the HTML rendered by the PHP script like this:

ob_start( array(&$this,'writeCache') );

and in writeCache:

function writeCache($content)
{
    //data save
}

It gets the content and saves it to the file.

Now i have 3 party second script that gets HTML string and cleans it:

$content = htmLawed($content); 

the htmLawed does this:

1. Interpreting $content
2. ob_start()
3. render new content
4. gets the result of the render and returns

So now when i put it together:

function writeCache($content)
{
    $content = htmLawed($content); 
    //data save
}

I get error:

Fatal error: ob_end_clean(): Cannot use output buffering in output buffering display handlers

So is there any way to escape with content from output buffering display handler so i can pass it to the htmLawed and it will be able to do ob_start()?

The error you are receiving indicates that you cannot call ob_start() from within the callback. I don't see why you would not be able to get around this, but you would need to restructure a bit more.

You might want to try intercepting the contents of the output buffer and processing it with htmLawed() before it goes to the output buffer callback.

echo htmLawed(ob_get_clean());
ob_end_clean();