用php加载https网站


load https website with php

嗨,我有以下问题,

我想用php开发一个网站。我使用了CURL,但在我的服务器上我设置了open_basedir。

因此,我收到以下错误消息:

CURLOPT_FOLLOWLOCATION在safe_mode或中设置了open_basedir时无法激活

代码为:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$store = curl_exec ($ch);
$error = curl_error ($ch);
return $store;

有没有其他方法可以使用php加载网站?!

感谢

您可以尝试使用file_get_contents():获取网站的内容

 $content = file_get_contents('http://www.example.com/');
 // to specify http headers like `User-Agent`,
 // you could create a context like so:
 $options = array(
   'http' => array(
      'method' => "GET",
      'header' => "User-Agent: PHP'r'n"
   )
 );
 // create context
 $context = stream_context_create($options);
 // open file with the above http headers
 $content = file_get_contents('http://www.example.com/', false, $context);