Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP的最大执行时间_Php - Fatal编程技术网

PHP的最大执行时间

PHP的最大执行时间,php,Php,我正在从一个网站下载图像,出现了一个错误,显示“超过了30秒的最大执行时间”,图像下载停止。我尝试添加我认为可以解决问题的以下代码行: ini_set('max_execution_time', 0); //zero means forever I think, I also tried 200 or 300 seconds 它没有给我错误,但是执行停止了(我的意思是图像停止下载) 如何使执行时间延长到300秒?有什么解决办法吗 提前谢谢 编辑: function save_image($in

我正在从一个网站下载图像,出现了一个错误,显示“超过了30秒的最大执行时间”,图像下载停止。我尝试添加我认为可以解决问题的以下代码行:

ini_set('max_execution_time', 0); //zero means forever I think, I also tried 200 or 300 seconds
它没有给我错误,但是执行停止了(我的意思是图像停止下载)

如何使执行时间延长到300秒?有什么解决办法吗

提前谢谢

编辑:

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);
    }
和方法调用:

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

                        }

                    }   
foreach($li->find('a[class=thumbnail]”)作为$img)
{
foreach($img->find('img')作为$e)
{   
$image++;
回声“src.”\“/>“
”; 保存图片($e->src,'thumbs/image'.$image..JPG'); } }
这就是我正在使用的代码

set_time_limit(0);
确保它位于文档的顶部,就在


确保它位于文档的顶部,就在
之后,您应该使用
设置时间限制(0)
()。

您应该使用
设置时间限制(0)
()。

或者,您可以更改php.ini文件中的
最大执行时间
,使其与您的需要相匹配。

或者,您可以更改php.ini文件中的
max\u execution\u time
,使其符合您的需要。

您使用的函数可能有时间限制。给我们看看你的代码。你使用的函数可能有时间限制。给我们看看你的代码。