PHP - nested output buffering

somerandomusername picture somerandomusername · May 17, 2012 · Viewed 9.6k times · Source

I have function that has :

ob_start();
//Include of some files
$content = ob_get_contents();
ob_end_clean();

Now in those includes is another function that uses the same code, and they seem to conflict. Is it possible to use them like this?

Answer

d4rkpr1nc3 picture d4rkpr1nc3 · May 17, 2012

Try using output buffer like this :

ob_start();
// your includes
echo ob_get_clean();

Use this in all of your includes, and you will not get any errors