PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, January 4, 2022

[FIXED] http.so loaded but http_get undefined

 January 04, 2022     http, lamp, php     No comments   

Issue

I have LAMP installed on my linux distribution:

///

PHP 5.4.9-4ubuntu2.4 (cli) (built: Dec 12 2013 04:29:20) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

///

In order to use http_get from pecl_http php extension I have explicitly installed it and added the http.so extension to php.ini.

Now I am in the following scenario. Using the simple php code below:

echo var_dump(extension_loaded("http"));

echo var_dump(extension_loaded("raphf"));

echo var_dump(extension_loaded("propro"));

echo var_dump(function_exists("http_get"));

$response = http_get("www.google.com");

echo $response;

I got the following results:

///

boolean true

boolean true

boolean true

**boolean false**

I am not sure why extension_loaded("http") returns true but function_exists("http_get") returns false, so I cannot use the function http_get without getting the following in the Apache log file

"[Tue Dec 31 12:32:26 2013] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function http_get() in /home/user/main.php on line 32"

Could you please help me troubleshooting this?

(same issue using the console interactive mode php -a)

phpinfo() shows:

///

http

HTTP Support enabled Extension Version 2.0.3

Used Library Compiled Linked libz 1.2.7 1.2.7 libcurl 7.29.0 7.29.0 libevent disabled disabled

Directive Local Value Master Value http.etag.mode crc32b crc32b

///

Thanks


Solution

As Michael Berkowski says, the 2.x branch is totally new and it works with a different API.

You can go with the 1.x branch and use the old functions this way:

pecl uninstal pecl_http
pecl install pecl_http-1.7.6

Then you can use http_get

Anyway, if this is a fresh new project, it is recommended to go with the newest API.



Answered By - Alex Barroso
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing