php - 通过 allow_url_fopen=0 中的服务器配置

标签 php warnings

运行脚本时出现以下错误。报错信息如下...

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/

相关文章:

php - PHP5错误..无法加载动态库

c++ - 即使重载 = 运算符也无法生成赋值运算符

java - 如果接口(interface)方法有多余的修饰符,Eclipse 中可能会收到警告吗?

arrays - Perl:如何在新哈希中声明空数组引用?

php - 如何将点符号数组扩展为完整的多维数组

php - 将数据库翻译成不同的语言

上传后php简单图片调整大小

c - 如何消除: [Warning] converting to `int' from `double'

ruby-on-rails - 如何破解 boot.rb 以停止烦人的警告? Gem::SourceIndex#search 对字符串模式的支持已弃用

php - 警告 : ftp_login(): User cannot log in, 主目录不可访问