$c = curl_init('http://numbersapi.com/09/27');
// 告诉cURL返回字符串形式的响应,
// 而不是立即打印
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
// 执行请求
$fact = curl_exec($c);
?>
Did you know that $fact ?>
浏览器执行后返回
Fatal error: Uncaught Error: Call to undefined function curl_init() in D:\PHP\Apache24\htdocs\example11-6.php:3 Stack trace: #0 {main} thrown in D:\PHP\Apache24\htdocs\example11-6.php on line 3
命令行键入
php -m
发现没有curl模块,那么如何加载curl模块呢?
在php.ini里面找到;extension=curl 把前面的;去掉,保存,然后重启apache
如果没有这一项,或者开启以后还没有生效,那么就要检查ext/php_curl.dll 这个文件是否存在,不存在的话,就下载一个,放到ext文件夹下,然后按上面的方法开启,重启apache
开启curl_init
1、把php目录中的libeay32.dll和ssleay32.dll拷到c:\windows\system32里面。
2、最后要重启IIS。
1.缺少curl模块,打开php.ini配置文件,将注释取消,ctrl+s保存
2.重启服务器(重点)
通过PHP curl模块发送请求时,出现 Fatal error: Uncaught Error: Call to undefined function curl_init()。
出现这种情况的原因有以下两点:
1、curl模块不存在
2、curl模块存在,但是php.ini配置文件中未开启php_curl.dll即;extension=php_curl.dll之前的;没有去除。
参考解决办法
https://blog.csdn.net/qq_34430649/article/details/103932380