2 回答
TA贡献1864条经验 获得超6个赞
我相信您正在寻找中止功能:
function (Base $f3) {
// process request and send response to client (could be a redirect status)
$f3->abort(); // disconnect the client
// perform consuming task here
}
这基本上是 Pavel Třupek 建议的解决方案,为方便起见,封装在一个方法中。
TA贡献1856条经验 获得超17个赞
尝试通过 curl 调用页面,例如:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt ($curl, CURLOPT_POST, FALSE);
curl_setopt($curl, CURLOPT_TIMEOUT, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, false);
curl_setopt($curl, CURLOPT_FORBID_REUSE, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 1);
curl_setopt($curl, CURLOPT_DNS_CACHE_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_FRESH_CONNECT, true);
curl_exec($curl);
curl_close($curl);
它调用 url 并立即使其超时。
然后在你昂贵的脚本中:
header("Connection: close\r\n");
header("Content-Encoding: none\r\n");
header("Content-Length: 1");
ignore_user_abort(true);
//your code
- 2 回答
- 0 关注
- 136 浏览
添加回答
举报