Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Output Control Functions : ob_flush

ob_flush

Flush (send) the output buffer (PHP 4 >= 4.2.0, PHP 5)
void ob_flush ( )


Code Examples / Notes » ob_flush

24-jun-2005 02:27

You must call them in the correct order.
ob_flush();
flush();


reynard hilman

when using command line php, if somewhere in your script you have ob_start(), you have to call ob_end_flush() first, and then you can call these functions:
flush();
ob_flush();
without calling ob_end_flush first, flush and ob_flush does not have any effect, at least that's what I experienced.


jeremy

we had problems with flushing data to the browser. a simple call to ob_flush() or flush() would not work. We found that repeatly calling theses fuctions did work however.
<?
flush();
ob_flush();
flush();
ob_flush();
flush();
ob_flush();
?>
go figure!


solidli

Use an '@' sign as "@ob_flush();" to avoid the following message:
Notice: ob_flush(): failed to flush buffer. No buffer to flush. in /etc/www/test.php on line 88


22-sep-2005 02:37

I was having problems with output buffering which seemed to be active by default on the server, although phpinfo said something else..
In any case I needed to know that when I ran ob_start, it would start at the top level, so I could use ob_flush as it's intended without having to call multiple ob_flush in-script - this is what I did:
<?php
// make sure output buffering is off before we start it
// this will ensure same effect whether or not ob is enabled already
while (ob_get_level()) {
ob_end_flush();
}
// start output buffering
if (ob_get_length() === false) {
ob_start();
}
?>
Then I could call ob_flush(); followed by flush(); and get the output I wanted, which I didn't if I started the script with just ob_start();
This was on a windows apache 2 server with php 5.0.4 btw.


14-jan-2003 04:23

As far as I can tell the only way to mimic ob_flush()'s behaviour on PHP < 4.2.0 is calling ob_end_flush() followed by ob_start().

Change Language


Follow Navioo On Twitter
flush
ob_clean
ob_end_clean
ob_end_flush
ob_flush
ob_get_clean
ob_get_contents
ob_get_flush
ob_get_length
ob_get_level
ob_get_status
ob_gzhandler
ob_implicit_flush
ob_list_handlers
ob_start
output_add_rewrite_var
output_reset_rewrite_vars
eXTReMe Tracker