Jump to content

Displaying as PHP runs.


Michdd

Recommended Posts

I noticed that if I'm running something that uses a lot of resources and won't completely finish (Like a really long loop) in a short period of time it will output to the browser, but continue to run and update as it outputs. (Because there's an echo in the loop) But I also noticed I don't get the same effect when this inside of a function.

 

while(something)
{
     echo 'foobar';
}

 

as opposed to:

 

function runWhile()
{
     while(something)
     {
          echo 'foobar';
     }
}

 

The first will output as it goes along, as opposed to the second which won't load the page the same way.

 

Why is this, and is there any way to make the second behave the same as the first?

Link to comment
Share on other sites

Actually.. I think it's something else..

 

What I'm doing takes a long time to complete (more than 10 minutes depending on the scale of the current operation). It seems to actually be doing it on both ways. Within the loop the opperation that I'm doing takes between 0.06 and 0.5 seconds. Depending on the method of which I'm doing it, I'm still working out the most efficient way. It seems that when it's working at about 0.06 seconds/loop it displays line and line and kind of looks like a live thing. But when it takes long, like .5seconds /loop it goes and stops. It won't display anything for a few minutes, then it'll display the results from the first couple hundred loops, and a few minutes later it'll display the next couple hundred.

Link to comment
Share on other sites

Web server. First I was testing it on my local web server, which is much slower than my paid hosting. So yea, same as what I said before, when it runs on a faster server it's like constant information 'pouring' in. But locally (slower) it's like stop and go.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.