I need to do some long process using Python which will be called using PHP(my main language) and display the result real time.
Lets say this is my Python script(a.py
).
import time
for x in range(10):
print "S;adasdasd;",x
time.sleep(0.5)
I have try so many example from internet but always get same result. PHP always wait until script is done then displaying it.
Here is one of so many code i have tried.
header( 'Content-type: text/html; charset=utf-8' );
$handle = popen('python folder\\a.py', 'r');
while (!feof($handle)) {
echo fgets($handle);
flush();
ob_flush();
}
pclose($handle);
Did I miss something?