Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2006
    Thanked 0 Times in 0 Posts

    while loop do function in background


    I have a while Loop that works something like this (I've simplified it so you can see the general logic of what I'm trying to accomplish):

    $i = 1;
    while (!file_exists($completed_file))
        -- progress bar code here --
        if ($i == 1)
    Basically, I want to output a progress bar while I perform a task in the background. When the task is completed it writes a $completed_file txt file, so I know when to stop the progress bar.
    The problem is that when it gets to the ProcessTask() function, it stops to run that WHOLE function. So basically it sits at 10% until the ProcessTask function is completed, and then it outputs everything to the page. Instead of that I want it to run the Function in the background, allowing my progress bar to run smoothly and completely.
    Is there a way to run a task/function in the background of the while loop, so my progress bar doesn't get interrupted?
    Your advice/experience is very much appreciated.

  2. #2
    Regular Coder
    Join Date
    Apr 2007
    Thanked 19 Times in 19 Posts
    You'll wanna look into ob_end_flush and flush to turn output buffering off and force output


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts