curl - 对未定义函数 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 的作者。
我该如何解决这个错误?
解决方案
好像没有安装 cUrl。例如,如果您使用的是基于 apt 的 linux 发行版,请使用:
apt-get install php5-curl
推荐阅读
- apache - 如何在 MacOS Mojave 上安装 Apache Atlas 1.1.0?
- postgresql - 如果 id 是 bigserial,Postgres 分区不能与休眠一起使用
- java - 仅在 java 中的序列化上重命名字段
- elasticsearch - 如何在弹性搜索中将嵌套文档存储为字符串
- xamarin.forms - 从浏览器中的 webview 打开链接,xamarin 表单中没有标题/地址栏
- python - 带有反应的 Django 休息框架 - 前端的空白页面
- linux - 如何将 fzf 绑定到 zsh 密钥?
- amazon-web-services - 任何 AWS 服务来存储 lambda 或 ec2 主机使用的配置?
- python - Django restful create api 将新条目标记为在创建时编辑
- css - 使用uikit在手风琴中的垂直虚线