title: handling script timeout in PHP
body: <p>I have been asked to write a script which will parse all href's in a page and then visit each href and check if each page is up and running ( using the HTTP code from CURL calls) . I have something like below :</p>
  
  <pre><code>&lt;?php foreach($links_array as $link_array): //$links_array are a tags
                  $link_array=str_replace("'", "\"", $link_array); // if href='link' instead of href="link"
                  $href= get_attribute($link_array, "href");
                  $resolved_address= resolve_address($href, $page_base);
                  $download_href= http_get($resolved_address,$ref );
                  $url=$download_href['STATUS']['url'];
                  $http_code=$download_href['STATUS']['http_code'];
                  $total_time=$download_href['STATUS']['total_time'];
                  $message=$status_code_array[$download_href['STATUS']['http_code']];
                  // $status_code_array is an array 
                  //if you refer to its index using the http code it give back the human
                  //readable message of the code 
                  ?&gt;
                  &lt;tr&gt;
                  &lt;td&gt;&lt;?php echo $url ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $http_code ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $http_code ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $total_time ?&gt;&lt;/td&gt;
                  &lt;/tr&gt;
             &lt;?php endforeach;?&gt;
  </code></pre>
  
  <p>The script works for pages with small number of hrefs but if a page has many hrefs the script times out . I have tried increasing max_execution_time in php.ini but this doesnt seem to be an elegant solution . My questions are 
  1) How does production software works in these type of cases which takes a long time to execute . 
  2) Can I continue making CURL calls by catching the fatal "Maximum execution time of 60 seconds exceeded"error ? 
  3) Also it will be better if I can make a curl call for the first href , check for the code, print it using HTML  and then make the next curl call for the second href , check for the code , print it and so forth . How can I do this ? </p>
  
  <p>Please bare with my ignorance I am three months into web programming .</p>