Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: Get output before script is finished

Tags:

php

I have a script named data.php that looks like this:

/* do some stuff */
echo $result;
/* do some other stuff (eg database operations) */

I need to use the output of data.php in another script but I don't want the caller script to wait until data.php is finished.

What's the easiest way to do this?

Thanks in advance!

like image 521
Daniel Avatar asked Nov 20 '10 22:11

Daniel


2 Answers

Take a look at the flush() function: http://php.net/manual/en/function.flush.php

like image 61
ryanbrainard Avatar answered Sep 30 '22 19:09

ryanbrainard


Theoretically speaking (writing) one script should output to a stream, and the other should read from the same stream.
A good (and simple) example would be one file writes to a file on HD, the other reads from it. Simplest, but not the best.

like image 25
Itay Moav -Malimovka Avatar answered Sep 30 '22 18:09

Itay Moav -Malimovka