maximum execution time for PHP
<p>I am working to download images from a website and there comes an error saying <code>"Maximum execution time of 30 seconds exceeded"</code> and the downloading of images stopped. And I tried to add the following line of code that I thought could solve the problem:</p>

<pre><code>ini_set('max_execution_time', 0); //zero means forever I think, I also tried 200 or 300 seconds
</code></pre>

<p>And it didn't give me errors BUT the execution stopped (I mean the images stop downloading).</p>

<p>How can I make the execution time extend like 300 seconds? Is there any solution for this?</p>

<p>Thanks in advance!</p>

<p>Edit:   </p>

<pre><code>function save_image($inPath,$outPath)
    { 
$in=    fopen($inPath, "rb");
$out=   fopen($outPath, "wb");
while ($chunk = fread($in,8192))
{
    fwrite($out, $chunk, 8192);
}
fclose($in);
fclose($out);
    }
</code></pre>

<p>And a method call:</p>

<pre><code>foreach($li-&gt;find('a[class=thumbnail]') as $img) 
                    {
                        foreach($img-&gt;find('img') as $e)
                        {   
                            $image++;           
                           echo "&lt;img src=\"" . $e-&gt;src . "\"/&gt;" . "&lt;br&gt;";
                           save_image($e-&gt;src, 'thumbs/image'. $image .'.JPG');

                        }

                    }   
</code></pre>

<p>That is the code that I'm using</p>
