0

What I want to do is to use php to make http request, so that I install http extension and it seems successful, because if I run phpinfo(), I can http extension clearly.

But the issue here is that the http function never works, even for the simplest one.

For example, if I tried the following two scenarios:

  1. echo 1; echo http_request(HTTP_METH_GET,"http://www.google.com");

I will got "1" as return.

  1. echo http_request(HTTP_METH_GET,"http://www.google.com"); echo 1;

I didn't get anything.

Can anyone help me with it? I have spent too much time on it. - Thanks very much.

ylongqi
  • 5
  • 2
  • Please turn on your error reporting (http://php.net/manual/en/function.error-reporting.php) temporarily so we can see what the error says, or find your error_log (http://php.net/manual/en/function.error-log.php) location and find the error. You might also try the curl functionality, or fopen (assuming you have permissions to open URLs with it?)? – Hans Oct 01 '14 at 03:28
  • @Hans It's quite weired though. - Just I posted here, it seems that http_request is an "infinite loop" because "echo 1" never execute in the second case. But for the first case, I can get "echo 1". – ylongqi Oct 01 '14 at 04:22
  • @Hans After I add "error_reporting" in the php code, I didn't see any report yet. Do I need to go to somewhere else in the file system to get to report? Thanks – ylongqi Oct 01 '14 at 04:23
  • @Hans Above is my code and it didn't print anything – ylongqi Oct 01 '14 at 04:27

3 Answers3

0

Please check whether there is a http.so file in your php extension library usually it locates at /usr/lib/php/extensions/no-debug-no-zts-.

If there it is, add a php.ini file in /etc/

and a line extension=http.so

I think there should be no problem.

Justin Civi
  • 893
  • 1
  • 9
  • 15
0

I think you just need to make some changes in your php.ini file

Change enable_dl = Off to enable_dl = On

Have a look here too

Community
  • 1
  • 1
Avinash Babu
  • 6,171
  • 3
  • 21
  • 26
0

May be you have installed version 2.* of pecl_http that is very defferent from and incompatible with version 1.*.

p.s. you can check version in phpinfo() output

Alex Belyaev
  • 1,889
  • 2
  • 12
  • 14