欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php http请求

程序员文章站 2022-04-16 16:41:32
...
/** * HTTP 请求数据 * @param  string $url URL * @return $data * @author Jack  */function https_request($url,$data = null){    $curl = curl_init();    curl_setopt($curl, CURLOPT_URL, $url);    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);    if (!empty($data)){        curl_setopt($curl, CURLOPT_POST, 1);        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);    }    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);    $output = curl_exec($curl);    curl_close($curl);    return $output;}
相关标签: php http请求