GeorgeWang地字3号

JQuery、Node.js http://www.pecloud.cn/

导航

Curl 常用函数之GET

function curl_get($url, array $get = NULL, array $options = array()) {

    $defaults = array(

        CURLOPT_URL => $url . (strpos($url, '?') === FALSE ? '?' : '') . http_build_query($get),

        CURLOPT_HEADER => 0,

        CURLOPT_RETURNTRANSFER => TRUE,

        CURLOPT_TIMEOUT => 4

    );

    $ch = curl_init();

    curl_setopt_array($ch, ($options + $defaults));

    if (!$result = curl_exec($ch)) {

        trigger_error(curl_error($ch));

    }

    curl_close($ch);

    return $result;

}

posted on 2011-02-20 14:18  GeorgeWang  阅读(244)  评论(0编辑  收藏  举报