Hi All, I have a PHP script that runs in a while loop which takes about 10 minutes to run. I want to output updates to the screen whilst this is running but it waits until the script is finished then outputs it all in one go. Is there anyway to make it output as its going along? Thanks Matt
I don't think it's possible. Server sends page to the browser after page is generated. I had similar problem with PHP task running almost an hour. To avoid timeouts and other problems, I would create new task request in database and initiate cron job to start the process. While working on the task, cron job would update status in database. When task request is created, I redirect browser to the page that is checking on task status every few seconds using AJAX.
ob_start(); while ($status == 'single') { echo 'having fun ... '; ob_end_flush(); flush(); $status = go_date(); } PHP: