【问题标题】:curl_init() has been disabled for security reasonscurl_init() 出于安全原因已被禁用
【发布时间】:2014-03-31 07:30:03
【问题描述】:
$url= "http://api.stackoverflow.com/1.1/search?tagged=php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_ENCODING, ""); // this will handle gzip content
$result = curl_exec($ch);
curl_close($ch);
print $result;

错误

Warning: curl_init() has been disabled for security reasons on line 2

Warning: curl_setopt() has been disabled for security reasons on line 3

Warning: curl_setopt() has been disabled for security reasons on line 4

Warning: curl_setopt() has been disabled for security reasons on line 5

Warning: curl_setopt() has been disabled for security reasons on line 6

Warning: curl_exec() has been disabled for security reasons on line 7

Warning: curl_close() has been disabled for security reasons on line 8

我可以知道我的 Curl 不工作的原因吗?

【问题讨论】:

    标签: php curl


    【解决方案1】:

    如果你在 xampp 上看下面

    How to enable curl in xampp?

    你应该只需要改变这个 php

    C:\Program Files\xampp\php\php.ini

    【讨论】:

    • 不,我在 localhost (xampp) 上检查它
    【解决方案2】:

    从您的 php.ini 中删除 disable_functions 中的上述函数。

    How to locate the php.ini file (xampp)

    php.ini file is available in xamp folder

    【讨论】:

      【解决方案3】:

      联系您的主机! :)

      或者试试:

      file_get_contents('http://api.stackoverflow.com/1.1/search?tagged=php');
      // Most likely it's also blocked.
      

      您也可以尝试使用streams下载。

      或者使用sockets直接连接到服务器并发送HTTP请求并自己解析响应。

      有一些方法,不知道它们是否适用于您的设置...如果 cURL 不可用。

      【讨论】:

        【解决方案4】:

        打开您的php.ini 文件并检查那里的disable_functions。看看你的curl_init 是否装在那里!这里是More information

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-12-05
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-06-30
          • 2016-02-07
          相关资源
          最近更新 更多