PHP   发布时间:2019-11-21  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了php – 如何知道curl_multi_exec中哪个URL失败?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我编写了一个类,以便更容易使用多个cURL请求,当我收到404错误或任何其他错误时,我想记录错误.
我已经将CURLOPT_FAILONERROR设置为true. @H_673_3@我目前正在使用curl_multi_info_read().

@H_673_3@这是我的代码:

$active = null;
    do {
        $multi_exec = curl_multi_exec($this->_multi_handle,$activE);
    } while ($multi_exec == CURLM_C@R_944_10636@mULTI_PERFORM);

    while ($active && $multi_exec == CURLM_OK) {
        if (curl_multi_SELEct($this->_multi_handlE) != -1) {
            do {
                $multi_exec = curl_multi_exec($this->_multi_handle,$activE);
                $info = curl_multi_info_read($this->_multi_handlE);
                if ( $info['result'] != 0 ) {
                    $this->_errors[] = $info; // currently storing the whole array
                }
            } while ($multi_exec == CURLM_C@R_944_10636@mULTI_PERFORM);
        }
    }
@H_673_3@错误的结果是这样的数组:

Array
(
    [0] => Array
        (
            [msg] => 1
            [result] => 22 // on success this is 0
            [handle] => @R_262_5550@e id #4 // does this Help in finding the url if I have the handle ID ?
        )
@H_673_3@那么如何才能获得发生错误的URL?这只给了我句柄资源ID

@H_673_3@并提前感谢.

解决方法

根据您的实际需要,您可以将此句柄传递给 curl_errorcurl_errno函数以检查错误,并且可以使用 curl_getinfo从该句柄中提取URL:
curl_geTinfo($info['handle'],CURLINFO_EFFECTIVE_URL);

大佬总结

以上是大佬教程为你收集整理的php – 如何知道curl_multi_exec中哪个URL失败?全部内容,希望文章能够帮你解决php – 如何知道curl_multi_exec中哪个URL失败?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。