就像人们说的,检查配置。
phpinfo.php
<?php
phpinfo();
?>
在网页上搜索 OpenSSL。另外,不要忘记在更改 php.ini 文件后重新启动 WebServer。
如果您不能使用file_get_contents(),请改用 cURL(如果可用),它在许多方面都更好并且更快。
function url($url,$option = null) {
$cURL = curl_init();
if ($option) {
curl_setopt($cURL, CURLOPT_URL, $url.$option);
} else {
curl_setopt($cURL, CURLOPT_URL, $url);
}
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cURL, CURLOPT_AUTOREFERER, 1);
curl_setopt($cURL, CURLOPT_HTTPGET, 1);
curl_setopt($cURL, CURLOPT_VERBOSE, 0);
curl_setopt($cURL, CURLOPT_HEADER, 0);
curl_setopt($cURL, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($cURL, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($cURL, CURLOPT_DNS_USE_GLOBAL_CACHE, 0);
curl_setopt($cURL, CURLOPT_DNS_CACHE_TIMEOUT, 2);
$output['page'] = curl_exec($cURL);
$output['contentType'] = curl_getinfo($cURL, CURLINFO_CONTENT_TYPE);
curl_close($cURL);
return $output;
}
$page = url('https://example.com/','i/like/subfolders');