Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - nested output buffering

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?

like image 983
somerandomusername Avatar asked May 17 '12 13:05

somerandomusername


2 Answers

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

like image 149
d4rkpr1nc3 Avatar answered Nov 09 '22 19:11

d4rkpr1nc3


Output buffering should be stackable, you just need to match ob_start with ob_end_clean. See http://php.net/ob_start

like image 28
Michal Čihař Avatar answered Nov 09 '22 17:11

Michal Čihař