Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get using php?

Tags:

php

I know that this is a simple question for PHP guys but I don't know the language and just need to do a simple "get" from another web page when my page is hit. i.e. signal the other page that this page has been hit.

EDIT: curl is not available to me.

like image 360
Guy Avatar asked Oct 19 '08 18:10

Guy


2 Answers

If curl wrappers are on (they are per default), you can use:

file_get_contents('http://www.example.org');

Note that this happens synchronous, so before the request has completed, your page won't either. It would be better to log access to a logfile (or database) and export the data occasionally. Alternatively, you could do the request after your page has completed, and output has been sent to the client.

like image 191
troelskn Avatar answered Nov 05 '22 06:11

troelskn


Beware file_get_contents() and fopen():

If PHP has decided that filename specifies a registered protocol, and that protocol is registered as a network URL, PHP will check to make sure that allow_url_fopen is enabled. If it is switched off, PHP will emit a warning and the fopen call will fail.

like image 22
eyelidlessness Avatar answered Nov 05 '22 04:11

eyelidlessness