Jump to content
  • Advertisement
Sign in to follow this  
miner2049er

[web] Handling extended script execution times

This topic is 5457 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

A couple of questions: (1) I have some PHP code that may take a while to execute - say 30-45 seconds or more - and I'm concerned that a browser may give up, and report an error because a page is not returned within a certain amount of time. How can I handle this? Should my PHP script (that generates the webpage) call another PHP script to do the long-processing task, allowing it to exit earlier (with a generated webpage), or what? (2) (a) I'm interested to know how some of these travel sites (Orbitz, Priceline etc.) can go off and do a search, that sometimes goes on for a while. (b) And sometimes I've noticed these types of pages will refresh, saying things like "Hang on in there... we're still searching." Does anybody have any advice regarding these questions, or pointers to more information? Thanks in advance, Simon.

Share this post


Link to post
Share on other sites
Advertisement
Your webserver probably has a setting in the php.ini that gives it a maximum execution time (default is 30 seconds).

Whether your visitors will sit through a 30 second script execution is debatable, but what I would do is bring up a "waiting..." page which then calls the script you want to execute.

Share this post


Link to post
Share on other sites
There's a setting in your php.ini (max_execution_time) that defines how long a script is allowed to run.

You can either change this setting in the .ini file or override it directly in your script with the function set_time_limit(). This function takes one argument, the maximum exectution time in seconds. If you set this to 0 - set_time_limit(0) - the time limit gets disabled.

Further information can be found here:
- http://www.php.net/manual/en/function.set-time-limit.php
- http://www.php.net/manual/en/ref.info.php#ini.max-execution-time

Hope this helps.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!