I'm attempting to use the http_build_str()
and http_build_url()
functions. I've installed and enabled pecl_http already, but I still get this error:
Call to undefined function http_build_str()
I've verified up down and sideways that the extension is installed and enabled. I've also already encountered the kind of warning messages that happen if their permissions are set wrong, so I can rule that out as well.
Then I came upon extension_loaded() and get_extension_funcs(). Their results are a little confounding:
print_r(extension_loaded('http')); // true
print_rt(get_extension_funcs('http')); // []
Doing a sanity-check, I ran those functions against a different extension that I know works, and I did get some results in the function array. As you can clearly see, "http_build_str" and "http_build_url", are not part of get_extension_funcs()
's output as I would have expected. Can anyone please help?
In case it matters, I'm setting this up in a Docker container, and what I think the relevant portions of its configuration are as follows:
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
Seems the Php Manuel is a little out of date on this one. Don't know how I missed it, but this question is a duplicate of http.so loaded but http_get undefined.
The link in the comment answering this is dead, the official docs seem to have moved. https://mdref.m6w6.name/http/QueryString
Seems the functionality is all still there, just in the form of a few classes now instead of functions.
$params = ['test1'=>'val1','test2'=>'val2'];
$queryHandler = new QueryString($params);
$queryString = (string)$queryHandler;
print_r($queryString); // test1=val1&test2=val2