I have a problem with output buffering in laravel 4. This code works good in other frameworks but in laravel i get fatal error for ob_get_flush()
class Ajax
{
public function __construct()
{
if ( Request::ajax() )
{
ob_clean();
ob_start(function(){});
register_shutdown_function(array(&$this,'setOutput'));
}
}
public function setOutput()
{
$html = ob_get_flush();
}
}
error :
ob_get_flush(): failed to delete and flush buffer. No buffer to delete or flush
It's "just" a Notice, not an Error. Your buffer content is empty, so PHP (through laravel) sends you a notice because it has nothing to do with
ob_get_flush
. Maybe notices are disabled in other frameworks you tried. According to this answer, you can do something like this, if you want to make it work even if your buffer is empty:Hope it will help !