php - php pecl_http 已加载,但未定义任何函数
问题描述
我正在尝试使用http_build_str()
andhttp_build_url()
函数。我已经安装并启用了 pecl_http,但我仍然收到此错误:
Call to undefined function http_build_str()
我已经上下验证了扩展程序已安装并启用。如果他们的权限设置错误,我也已经遇到过那种警告消息,所以我也可以排除这种情况。
然后我遇到了 extension_loaded()和get_extension_funcs()。他们的结果有点令人困惑:
print_r(extension_loaded('http')); // true
print_rt(get_extension_funcs('http')); // []
进行完整性检查后,我针对我知道有效的不同扩展运行了这些函数,并且确实在函数数组中得到了一些结果。如您所见,“http_build_str”和“http_build_url”并不是get_extension_funcs()
我所期望的输出的一部分。有人可以帮忙吗?
万一这很重要,我将其设置在 Docker 容器中,我认为其配置的相关部分如下:
RUN apt-get update && apt-get install --no-install-recommends -y \
git-core \
build-essential \
openssl \
libssl-dev \
libcurl4-openssl-dev
RUN docker-php-ext-install pdo_mysql mbstring exif zip pcntl ftp
RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install gd
RUN pecl install propro raphf \
&& docker-php-ext-enable propro raphf \
&& rm -rf /tmp/pear
RUN pecl install pecl_http xdebug \
&& docker-php-ext-enable http xdebug \
&& rm -rf /tmp/pear
解决方案
似乎 PHP Manuel 在这个上有点过时了。不知道我是怎么错过的,但是这个问题是http.so loaded but http_get undefined的副本。
评论中回答这个问题的链接已经死了,官方文档似乎已经移动了。 https://mdref.m6w6.name/http/QueryString
似乎功能仍然存在,只是现在以几个类的形式而不是函数的形式。
$params = ['test1'=>'val1','test2'=>'val2'];
$queryHandler = new QueryString($params);
$queryString = (string)$queryHandler;
print_r($queryString); // test1=val1&test2=val2
推荐阅读
- node.js - 如何在 AWS Elastic Beanstalk 上部署 next.js?
- linux - 为旧键盘/隐藏设备编写 linux 内核模块/驱动程序
- visual-studio-code - 遇到 ninja 和 CMake 问题时如何在 VSCode 上构建 ESP 项目?
- r - 缺少数据的误差线性回归
- android - 如何在android上自定义通知
- android - 从 URL 中提取音频文件详细信息(mp3 文件)
- c# - CoPurchase Recommendation 引擎返回 NaN
- javascript - 未捕获的 RangeError:Int16Array 的字节长度应为 2 的倍数
- c++ - C++ 程序不适用于大输入(logic_error,_M_construct null 无效)
- android - 网络请求时我应该始终使用 viewmodescope 吗?