Home >Backend Development >PHP Tutorial >Send https request using php
This article mainly introduces using php to send https requests. It has certain reference value. Now I share it with everyone. Friends in need can refer to it
I will use it recently, so I wrote a program to test it. Use php to send an https request and run it directly in http://www.dooccn.com/php7/:
<?php function curl_get_https($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 跳过检查 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 跳过检查 $tmpInfo = curl_exec($curl); curl_close($curl); return $tmpInfo; //返回json对象 } $url = "https://www.baidu.com"; // $url = "https://115.159.119.33"; $result = curl_get_https($url); var_dump($result); ?>
The result is OK
Related recommendations:
PHP publishes WebService instance sharing
php sends data to kafka implementation code
The above is the detailed content of Send https request using php. For more information, please follow other related articles on the PHP Chinese website!