第一种:
直接使用函数:
file_get_contents();
前提是需要php编译时候支持 ssl,也就是加上with=openssl选项,windows下则需要将extention=openssl.dll选项打开。
比如:echo file_get_contents('https://www.paypal.com/c2');即可打印出结果!
第二种:
使用CURL,当然你的php需要支持curl,linux中需要配置。。。,windows中需要配置。。。。(省略)
方法:
ob_start();
$url = ('https://www.paypal.com/c2');
$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;
原理是将内容打印到缓冲区,然后将缓冲区内容赋值给一个变量。
参考资料:
php支持curl扩展: