Fatal error: Call to undefined function http

I tried to make cross domain request in php coding using http_get. In my server, there is no required modules installed. I dont know what to install to make posible of doing http_get.

The error which i got was

Fatal error: Call to undefined function http_get() in C:xampphtdocsarticleindex.php on line 2

I tried to do so (PECL pecl_http >= 0.1.0) http_get — Perform GET request

but, i did not find out solution.

So, please help me to run http_get coding. Thanks in advance.


I think that you have to enable extension=php_http.dll in your php.ini file and after that restart your Apache Server.
I advise you to use cURL instead of http_get() (same manipulation, you have to enable extension=php_curl.dll and restart apache)

Hope that Helps :)


To answer directly the question, you've to enable extension=php_http.dll in your php.ini an restart apache, but there's absolutely no need to use http_get() in our days.

Here's 3 good alternatives:

  • The php curl library
  • file_get_contents()
  • copy()

  • Curl usage:

    // Get cURL resource
    $curl = curl_init();
    // Set some options - we are passing in a useragent too here
    curl_setopt_array($curl, array(
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_URL => 'http://testcURL.com/?item1=value&item2=value2',
        CURLOPT_USERAGENT => 'User Agent X'
    ));
    // Send the request & save response to $resp
    $resp = curl_exec($curl);
    // Close request to clear up some resources
    curl_close($curl);
    

    file_get_content() usage:

    $my_var = file_get_contents("https://site/");
    

    copy() usage:

    copy("https://site/image.png", "/local/image.png");
    
    链接地址: http://www.djcxy.com/p/83040.html

    上一篇: devcon禁用不能禁用未找到的设备

    下一篇: 致命错误:调用未定义的函数http