FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » time consuming loop
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: time consuming loop [message #170873 is a reply to message #170865] Sat, 04 December 2010 12:51 Go to previous messageGo to previous message
Kim Andr Aker is currently offline  Kim Andr Aker
Messages: 17
Registered: September 2010
Karma:
Junior Member
På Sat, 04 Dec 2010 08:39:26 +0100, skrev Paul Fredlein
<paulfredlein(at)optusnet(dot)com(dot)au>:

> Hi,
>
> If I use a loop that's too time consuming the browser will complain. Is
> there a callback or threads or something I can use and only do a small
> number each time instead of the whole lot at once?
>
> for(short i = 0; i < LONG_INT; i++)
> {
> doSomething();
> }

Maybe it's not the browser complaining (at least not on its own) - I would
think your script runs into the maximum script execution time (by default
set to 30 seconds, but may differ depending on the host configuration).

One way to work around this, is to reset the counter after each loop using
set_time_limit().
http://php.net/set-time-limit

Like this:


for(short i = 0; i < LONG_INT; i++)
{
doSomething();
set_time_limit(30);
}

--
Kim André Akerø
- kimandre(at)NOSPAMbetadome(dot)com
(remove NOSPAM to contact me directly)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Demo PHP/Ajax slideshow server crashing
Next Topic: Apache + PHP module segfaults
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 14:15:34 GMT 2024

Total time taken to generate the page: 0.06264 seconds