InfiniteLoop InfiniteLoop - 1 year ago 265
PHP Question

PHP 7 copied php_http.dll into php/ext/ not working?

I should add that I'm not fishing for a cURL solution. I already know and do cURL. I want to see what happens in my experiment with an http function.

I'm running PHP 7 from a XAMPP installation at:


I downloaded a Windows, which was full of .dll files, then I copied the php_http.dll file into my php\ext folder, where all the other .dlls were found.

I edited my php.ini and added the line

in the alphabetical order of all the other extensions (as if that makes any difference).

Then I restarted Apache, and tried to perform a
$response = http_get($url);
but get the error "Call to undefined function http_get()".

Seems like I'm doing all the steps right, but the http functions just aren't working. Also, I looked at my phpinfo() and I don't see any reference to any PECL extension.

I read in another forum a similar problem, where this line was found in the Apache error.log:

C:\xampp\php\ext\php_http.dll' - The specified module could not be found.

The individual said he downgraded his php version, then repeated the steps and it worked.

Last night I downgraded from PHP 7 to PHP 5.6. I repeated the .dll copy to /ext, enabled php_http.dll in php.ini, and then got a different error:

HP Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_http.dll' - %1 is not a valid Win32 application.\r\n in Unknown on line 0

I found these Windows http extensions, again copied the .dll file, restarted Apache, but now I'm back to

PHP Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_http.dll' - The specified module could not be found.\r\n in Unknown on line 0

Answer Source

Instead of doing so many changes you could have simply used curl and get the same result. Reference to PECL on http_get has been removed. That version of PECL is for PHP 5.2.x . Which version of php you are using? instead you can use this function

function url_get($url)
    $ch = curl_init();    // initialize curl handle
    curl_setopt($ch, CURLOPT_URL,$url); // set url to post 
    curl_setopt($ch, CURLOPT_FAILONERROR, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
    curl_setopt($ch, CURLOPT_TIMEOUT, 10); // times out after 10s
    $urlcontent = curl_exec($ch); 
$url = "";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download