Forum Moderators: coopster
I'm trying to clean up my code but currently have ob_end_flush included at the bottom of every page/script and was wondering if it was even needed. Will the content of the buffer will be output at end of script execution even if ob_end_flush wasn't included?
Safest practice probably the following:
declare a function echoit() in some central file that gets called by all your scripts -
echoit($var){
echo $var;
}
and instead of ob_start(), try ob_start('echoit') (using echoit as the callback).
When used with a callback, ob_start sends the output at the end to this function.
And another thought: if you've got php installed on your local box, it's like 30 seconds and you have the answer to your own question. One place to get it: [apachefriends.org...] ('wow! apache has got some pretty hip-looking friends')
- preg_replace_callback()
- array_walk()
- array_filter()
- lots more array functions
- xml_set_element_handler()
- etc etc
I removed ob_end_flush and everything still worked and the output was sent to the browser after ob_start and even a nested ob_start worked without ob_end_flush for either.
One oddity I couldn't quite figure out was that I was able to echo functions like ob_get_length as long as the ob_end_flush wasn't called for either of the ob_start and nested ob_start. Yet if I put the ob_end_flush in the right spots then I couldn't echo it and it would actually cut short the output. In this case I was using phpinfo() and it stopped displaying everything after "Apache Environment" when using ob_end_flush and when not using ob_end_flush it echo'd the ob_get_length function and displayed the full phpinfo().
So basically it works without ob_end_flush.. I'm not sure how it does it.. and it seems to give more flexibility with regards to display.. but technically it's wrong without ob_end_flush. Maybe the server I was testing on was setup wrong. :P
Where can I find more information on php callback, I'm not sure exactly what it is but sort of understand how it might work.