简体   繁体   中英

How to make PHP Curl request not to wait?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM