PHP: Increasing a scripts runtime

Often when working with long php scripts you may need more time then is aloud. Recently when working with lirkr search engine I came across a problem where the server would time me out due to the script taking so long. The reason this was taking so long is because I had to read information from pages and load it into the search engines database word by word and check if the word already exists.

Here is a simple way to change the duration of time a script is aloud to be executed for.

1
2
3
<?php
ini_set(max_execution_time, "300");
?>

Be careful when using this script. If your code lasts longer then a few minutes then chances are the code is not very efficient, you have a infinite loop somewhere or you could just be working with a database that not a lot of people will ever have to use.

Related posts:

  1. Random Images Using A PHP Function: cj_random_image
  2. PHP – For loops
  3. The Beginners Guide to PHP
  4. Redundant Data Class in PHP {Theory}
  5. Ways to make you work more effectively from home
Caleb Jonasson

About: Caleb Jonasson

I am a web application developer currently spending my days coding at work, completing contracts and running around with my Nikon. This is my primary place for updates and everything code, technology and database related.