[wp-hackers] ob_start - good or bad?

Donncha O Caoimh donncha at linux.ie
Thu Apr 23 09:48:05 GMT 2009

If you use ob_start() and wait until the end of the PHP process to 
collect the output and do something with it (like WP Super Cache and 
other caching plugins do) you have to be careful about using objects.
The latest versions of PHP5 destroy objects during shutdown before all 
code has actually been run.

I had to "pre cache" a few blog options earlier in the process (into 
global variables) to get around this. What's worse, is that this 
destroying of objects doesn't always happen, and different versions of 
PHP5 do different things. It's head wrecking.


Simon Wheatley wrote:
> On Thu, Apr 23, 2009 at 10:35 AM, Otto <otto at ottodestruct.com> wrote:
>> Well, there's already a get_edit_post_link() function, so why not use
>> that instead? Okay, so it doesn't return all the a href stuff, but
>> that's easy to duplicate.
> I hadn't spotted that when I looked at the edit_post_link function
> somehow, thanks.. seems so obvious now I look again. :\
>> In general, it's a bad idea to use output buffering unless there's no
>> other way to do it. In the case of the given code, there's definitely
>> another way to do it.
> For the sake of my education (and accepting that get_edit_post_link is
> available for this specific case), why is ob_start, etc,  a bad idea?
> Thanks Otto.
> S

More information about the wp-hackers mailing list