【问题标题】:Php pecl_http loaded, but not defining any functionsphp pecl_http 已加载,但未定义任何函数
【发布时间】:2020-01-30 19:06:01
【问题描述】:

我正在尝试使用 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】:

    似乎 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-18
      • 1970-01-01
      • 2020-08-01
      • 1970-01-01
      • 2021-04-19
      • 2017-06-29
      • 1970-01-01
      • 2014-01-31
      相关资源
      最近更新 更多