08-22-2011, 11:07 AM
im testing the following script and it wont send 1 2 3 until the script has finished executing.
What can i do to flush the buffer after every echo statement??
08-22-2011, 01:09 PM
I think you need to use ob_start() (http://php.net/manual/en/function.ob-start.php) before any of that will work...
08-22-2011, 02:25 PM
ob_start turns on output buffering. ob_flush() will not work without it.
Unfortunately what you're trying to do even with flush will not work. This is because of the way sockets work internally to any operating system. Most sockets will read in 4Kb chunks so your output will not be even passed through to your ISP until it fills up its buffer. Even then your ISP will also perform the same action.
The only way content less than the buffer gets to you is when the output is finished - IE the system realises that there is no more and passes it on down the line. Not that you'll even notice this without any sleep() commands..