致命错误:脚本中超出了 30 秒的最大执行时间 [英] Fatal error: Maximum execution time of 30 seconds exceeded in script

查看:28
本文介绍了致命错误:脚本中超出了 30 秒的最大执行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一位客户收到与脚本超时相关的错误.我已经包含了下面的代码,但我认为问题在于需要延长超时时间.

I have a customer who is getting an error related to a script timeout. I've included the code below, but i think the issue is that the timeout needs to be extended.

这是我可以在代码中设置的内容,还是必须由网络主机 (GoDaddy) 设置?

Is this something I can set in the code, or does it have to be set by the web host (GoDaddy)?

致命错误:第 170 行 D:\hosting\123\html\siteame\wp-content\plugins\myplugin\myplugin.php 中超出了最大执行时间 30 秒

此时的代码是:

function my_copy_recurse($src,$dst){
    $dir = opendir($src); 
    @mkdir($dst); 
    while(false !== ( $file = readdir($dir)) ) 
    { 
        if (( $file != '.' ) && ( $file != '..' )) 
        { 
            if ( is_dir($src . '/' . $file) ) { 
                my_copy_recurse($src . '/' . $file,$dst . '/' . $file); 
            } 
            else { 
                copy($src . '/' . $file,$dst . '/' . $file); 
            } 
        } //THIS IS LINE 170
    } 
    closedir($dir); 
}

推荐答案

要限制最长执行时间,请使用 set_time_limit($seconds).如果将 $seconds 设置为零,则没有时间限制.所以只需在脚本的开头添加 set_time_limit(0) ,脚本就会运行到最后.但是如果用户的浏览器由于浏览器超时而断开连接,您的脚本可能会停止,因此您需要在脚本开头添加 ignore_user_abort(true) 以忽略它并一直工作到脚本结束.

To limit the maximum execution time use set_time_limit($seconds). If set $seconds to zero, no time limit is imposed. So just add set_time_limit(0) at the beginning of the script and script will work till the end. But if user's browser disconnects due to browser timeout your script could be halted, so you need to add ignore_user_abort(true) at the beginning of the script to ignore it and work exactly till the end of the script.

这篇关于致命错误:脚本中超出了 30 秒的最大执行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆