运行脚本时出现以下错误。报错信息如下...
Warning: file_get_contents() [function.file-get-contents]: https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/satoship/public_html/connect.php on line 22
我知道这是服务器问题,但我需要对服务器做什么才能消除上述警告?
最佳答案
@blytung 有一个很好的函数来替换那个函数
<?php
$url = "http://www.example.org/";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$contents = curl_exec($ch);
if (curl_errno($ch)) {
echo curl_error($ch);
echo "\n<br />";
$contents = '';
} else {
curl_close($ch);
}
if (!is_string($contents) || !strlen($contents)) {
echo "Failed to get contents.";
$contents = '';
}
echo $contents;
?>
关于php - 通过 allow_url_fopen=0 中的服务器配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21677579/