Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show results while script is still executing

Tags:

php

Right now in order to see the results, I have to wait until the entire code is done executing. It hangs until it's complete and stays loading. Once it's finished it shows all the information I was looking for.. Is there anyway to show this while the script is still running? So say if I have a print somewhere at the top of my code, I want it to show when it's called not when the script is done executing.

Anyone know how to do this?

Thanks

like image 845
adam Avatar asked Mar 24 '11 06:03

adam


1 Answers

You can use output buffering like this:

ob_start();  echo('doing something...');  // send to browser ob_flush();  // ... do long running stuff echo('still going...');  ob_flush();  echo('done.'); ob_end_flush();  
like image 52
Rob Agar Avatar answered Sep 21 '22 14:09

Rob Agar