PHP之POST方法

function post($url, $postData = '', $timeout = 5)
​{
        $ch = curl_init();
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_POST, 1);
        if ($postData != '')
        {
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
        }
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        curl_setopt($ch, CURLOPT_HEADER, false);
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
}

 

你可能感兴趣的:(PHP之POST方法)