V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  Ech0o0  ›  全部回复第 1 页 / 共 1 页
回复总数  1
```php
<?php

set_time_limit(30);
ignore_user_abort(false);

header("Content-Length: 0");
header("Connection: Close");
echo str_pad('', ini_get('output_buffering'));
ob_end_flush();
ob_flush();
flush();

//耗时任务
sleep(10);
file_put_contents('test.log', date('Y-m-d H:i:s'), FILE_APPEND);
```

```php
<?php

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://127.0.0.1/async.php');
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_exec($curl);
curl_close($curl);

echo '结束了';
```

有局限性,最好还是用队列吧
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2173 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 05:23 · PVG 13:23 · LAX 22:23 · JFK 01:23
Developed with CodeLauncher
♥ Do have faith in what you're doing.