已加载Php pecl_http,但未定义任何功能

问题描述 投票:1回答:1

我正在尝试使用http_build_str()http_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 http module php-extension pecl
1个回答
0
投票

似乎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
© www.soinside.com 2019 - 2024. All rights reserved.