php - PHP 8.0 Curl 请求正在运行,但在日志中生成致命错误
问题描述
我在 xampp error_log (Ubuntu 20 -> /opt/lampp/logs/error_log) 中注意到:
thrown in /opt/lampp/htdocs/core/scrapers/ps3838/ps3838.rest.php on line 106
PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /opt/lampp/htdocs/core/scrapers/ps3838/ps3838.rest.php:106
Stack trace:
#0 /opt/lampp/htdocs/core/scrapers/ps3838/ps3838.rest.php(239): RestClient->request()
#1 /opt/lampp/htdocs/core/scrapers/ps3838/ps.scraper.php(158): Ps3838->get_odds()
#2 {main}
该错误是在我用来查询 api 的类中生成的。
if ($this->request_method === "POST") {
$this->ch = curl_init($url);
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $param);
} else {
$this->ch = curl_init($url."?".$param);
curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, "GET");
}
奇怪的是代码按预期工作!没有错误,我得到了响应......发生了什么 - 为什么它被记录为错误?它怎么能抛出一个致命的错误却又完美地执行?
解决方案
推荐阅读
- node.js - 如何获取数组中具有特定值的所有文档?
- discord - 为 discord.js 设置嵌入的反应角色时遇到问题
- html - 在不使用绝对值的情况下获得绝对行为
- python - 如何修复跨数组的python乘法错误
- css - 赛普拉斯测试字体中缺少的符号
- android - 带有过滤器的Android自定义列表视图不起作用
- ruby - Logstash 支持 BCFIPS 吗?如果是这样如何使 Log Stash 插件与 BFIPS 兼容?
- ruby-on-rails - rake routes 命令不起作用 - rake 版本 13.0.3
- r - 当行的其余部分重复时,如何通过对一列的值求和来合并表
- graphql - 如何将数组作为参数传递给 Nexus?如何使用 Prisma 从这个数组创建多个对象?