首页 > 解决方案 > 对未定义函数 curl_init() 的卷曲调用

问题描述

我正在使用 Windows 10,我在我的 php 脚本 cURL 中使用来获取一些资源:

<?php
// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => 'http://localhost/module/webservice.php/events/contentViewed/',
    CURLOPT_USERAGENT => 'User Agent X'
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
print_r($resp);
?>

但我得到这个错误:

致命错误:第 5 行 C:\wamp\www\testTracker.php 中调用未定义函数 curl_init()

我检查了我的 php.ini 文件,它extension=php_curl.dll已启用。此外,当我phpinfo()检查是否启用了 cURL 模块时,我只看到 cURL = Sterling Hughes 的作者。

我该如何解决这个错误?

标签: curlphp-5.5

解决方案


好像没有安装 cUrl。例如,如果您使用的是基于 apt 的 linux 发行版,请使用:

apt-get install php5-curl

推荐阅读