开发者

How to make PHP Curl request not to wait?

开发者 https://www.devze.com 2022-12-27 23:09 出处:网络
I\'ve a PHP function which fetches a Curl request. This request sometimes take longer开发者_如何学运维 time than expected and hence my php function takes longer to return.

I've a PHP function which fetches a Curl request. This request sometimes take longer开发者_如何学运维 time than expected and hence my php function takes longer to return.

In my particular case, output of curl request is not important. So is it possible with curl just to place a request and proceed without waiting for curl_exec() to finish?


PHP does not support multi-threading, so this is not possible. You can, however, limit the amount of time cURL will execute.

$max_exe_time = 250; // time in milliseconds
curl_setopt($curl_handle, CURLOPT_TIMEOUT_MS, $max_exe_time);

You can read about this configuration option and others: http://php.net/manual/function.curl-setopt.php

0

精彩评论

暂无评论...
验证码 换一张
取 消