phpwindowscurlwampservercurl-multi

How to check if multi_curl is supported on PHP?


I have a piece of PHP code that uses cURL to do post requests, it uses the curl_multi_* functions for performance.

It all works fine on my hosted PHP server.

But it fails on my WAMPServer at 127.0.0.1. Single cURL requests work just fine on the WAMPServer, but curl_multi_select() only ever returns -1 until the script finally times out.

The code... is Example #1 on PHP.net's manual page on curl_multi_exec: http://www.php.net/manual/en/function.curl-multi-exec.php Here's the snippet causing the infinite loop:

$active = null;

do {
    $mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);

while ($active && $mrc == CURLM_OK) {
    if (curl_multi_select($mh) != -1) {
        do {
            $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);
    }
}

Tested with Vista's firewall disabled.

Does anybody know how to get curl_multi_* working on WAMPServer or is there any way to detect support for curl_multi_* from within the PHP script so I could make a fallback?


Solution

  • use function_exists('curl_multi_select') to detect support.

    http://php.net/manual/en/function.function-exists.php