无法使用php和fopen打开https网站

1 php https fopen

我正在使用fopen来检索URL的内容.它适用于http网址,但不适用于https网址

谁能明白为什么?

<?php

//this works fine
echo ("<br><br>url 1 is ".OutputURL("http://nuenergy.acornsoftware.com.au/staff/interface/index.php"));

//returns nothing
echo ("<br><br>url 2 is ".OutputURL("https://nuenergy.acornsoftware.com.au/staff/interface/index.php"));

function OutputURL($url)
{
  $handle = fopen($url, "r");
  $contents = stream_get_contents($handle);
  fclose($handle);
  return $contents;
}
//
?>
Run Code Online (Sandbox Code Playgroud)

Ali*_*xel 5

您需要安装并使用PHP配置OpenSSL,我建议您在ServerFault上询问此问题.

此外,你可以使用file_get_contents()而不是OutputURL().