View Full Version : output of php script wont display in browser until the script has finished executing
08-22-2011, 12:07 PM
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, 02: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, 03: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..
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.