I want to make a page that will show some results after executing some processes. Each process may take 2-10 seconds. So instead of waiting for all the processes to complete, I want to print the result of each once it is completed.
Eg:
<?php
echo "1";
sleep(5); // some process that will execute 5 seconds
echo "2"
sleep(8); // some process that will execute 8 seconds
echo "3"
sleep(5); // some process that will execute 5 seconds
?>
So on opening this PHP file in browsers, "1" prints, after 5 seconds "2" and son on. How can I do that I PHP? One way to do that is to convert these to separate PHP files and load each of then with ajax. But I don't want to split it into different files.