第一种:
直接使用函数:
file_get_contents();
前提是需要php编译时候支持 ssl,也就是加上with=openssl选项,windows则需要将extention=openssl.dll选项打开
举例:
echo file_get_contents(‘https://https://qcodes.cn/’);
第二种:
使用CURL。当然,你的php需要支持curl,linux和windows都需要配置(此处省略,感兴趣的葫芦丝可以自行百度)
举例:
ob_start();
$url = (‘https://https://qcodes.cn/’);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec($ch);
$r = ob_get_contents();
echo $r;
原理是将内容打印到缓冲区,然后将缓冲区内容赋值给一个变量。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
相关文章
暂无评论...