调用未定义的函数curl_init(),但它已启用

时间:2013-01-09 10:05:18

标签: php curl wamp

我有WAMP,我正在使用Apache 2.2.22运行PHP 5.3.13。

我通过勾选php_curl启用了扩展程序。我重新启动了电脑。

我的代码说:

Fatal error: Call to undefined function curl_init() 

有人认为会出现什么问题吗?

我的phpinfo没有说任何关于卷曲的内容,但在phpini中它说:

;延长= php_bz2.dll

延长= php_curl.dll

代码调用它在这里:

class ***** {
  public static $oauth, $debug, $logger, $session_manager, $last_response;
  protected static $url, $client_id, $client_secret, $secret, $ch, $headers;

  const GET = 'GET';
  const POST = 'POST';
  const PUT = 'PUT';
  const DELETE = 'DELETE';

  public static function setup($client_id, $client_secret, $options = array('session_manager' => '*****Session')) {
  // Setup client info
  self::$client_id = $client_id;
  self::$client_secret = $client_secret;

  // Setup curl
  self::$url = empty($options['api_url']) ? 'https://api.*****.com:443' : $options['api_url'];
  self::$debug = false;
  self::$ch = curl_init();

此代码来自可信赖的API。我已经加星标,不需要分享。

3 个答案:

答案 0 :(得分:4)

将ext文件夹中的dll文件替换为正确的版本:

http://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/

我正在使用win 8 64bit,所以我的版本是:

http://www.mediafire.com/?0hm40owj08y68p7

答案 1 :(得分:1)

在php.ini文件中查找以下行:

;extension=php_curl.dll

如果在那里,请从头开始删除; ,然后重新启动服务器并重试。

答案 2 :(得分:0)

您是否偶然使用了64位版本的wampserver?

64位版本或Apache版本/ PHP版本的某些组合存在问题(似乎)

如果您转到wampserver homepage的下载部分,您可以下载不同的Apache / PHP版本进行测试,直到找到有效的版本。

I have answered this kind of question before here。希望能够对情况有所了解。

从我的另一个答案:

  

我几天前遇到过这个问题,唯一可以解决的问题是安装apache addon 2.2.9和php addon version 5.3.1