kevinkhan Posted August 22, 2011 Share Posted August 22, 2011 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?? <?php echo "1"; ob_flush();flush(); sleep(5); echo "2"; ob_flush();flush(); sleep(5); echo "3"; ob_flush();flush(); ?> Link to comment https://forums.phpfreaks.com/topic/245414-problem-sending-output-to-a-browser-while-php-script-is-running/ Share on other sites More sharing options...
trq Posted August 22, 2011 Share Posted August 22, 2011 HTTP isn't designed to work the way your after. Link to comment https://forums.phpfreaks.com/topic/245414-problem-sending-output-to-a-browser-while-php-script-is-running/#findComment-1260443 Share on other sites More sharing options...
codefossa Posted August 22, 2011 Share Posted August 22, 2011 The server runs the script, then sends the output to your browser. It waits until the script has finished before sending the output, so that would not work. If you run it through the terminal "php script.php", you would then be able to see it how you've asked, but not through a browser. Also, if it's a remote server, you would have to use SSH to run it from there, not the URL to a script. Link to comment https://forums.phpfreaks.com/topic/245414-problem-sending-output-to-a-browser-while-php-script-is-running/#findComment-1260454 Share on other sites More sharing options...
Muddy_Funster Posted August 22, 2011 Share Posted August 22, 2011 you do know what PHP's full name is right? Link to comment https://forums.phpfreaks.com/topic/245414-problem-sending-output-to-a-browser-while-php-script-is-running/#findComment-1260457 Share on other sites More sharing options...
titan21 Posted August 22, 2011 Share Posted August 22, 2011 You'll need to this with Javascript or if you're feeling brave AJAX - I'd stick with Javascript to begin with tho! Link to comment https://forums.phpfreaks.com/topic/245414-problem-sending-output-to-a-browser-while-php-script-is-running/#findComment-1260578 Share on other sites More sharing options...
cssfreakie Posted August 22, 2011 Share Posted August 22, 2011 You'll need to this with Javascript or if you're feeling brave AJAX - I'd stick with Javascript to begin with tho! even if your not brave, or got blue paint on your face. Ajax is the way to go. HAve a look in to jquery ajax. Quite some tutorials out there and within an hour you should be able to do some simple stuff with it. Link to comment https://forums.phpfreaks.com/topic/245414-problem-sending-output-to-a-browser-while-php-script-is-running/#findComment-1260607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.