Home > Backend Development > PHP Tutorial > php http请求

php http请求

WBOY
Release: 2016-06-23 13:06:27
Original
963 people have browsed it

/** * HTTP 请求数据 * @param  string $url URL * @return $data * @author Jack <yjwang088@163.com> */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;}
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template