出于安全原因,curl_init()已被禁用

时间:2014-02-27 17:25:23

标签: php curl

$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

我知道为什么我的卷发不起作用吗?

4 个答案:

答案 0 :(得分:3)

从您的php.ini中删除disable_functions上面的上述功能。

How to locate the php.ini file (xampp)

php.ini file is available in xamp folder

答案 1 :(得分:2)

如果你在xampp上看下面

How to enable curl in xampp?

你应该只需要改变这个php

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

答案 2 :(得分:1)

与您的托管服务商联系!:)

或尝试:

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

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

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

有很多方法,不知道他们是否可以使用您的设置...如果cURL不可用。

答案 3 :(得分:0)

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