NYCPHP Meetup

NYPHP.org

[nycphp-talk] calling another script within php

csnyder chsnyder at gmail.com
Tue Apr 19 17:56:02 EDT 2005


On 4/19/05, Wai Siow <rs234 at cornell.edu> wrote:

> I want to call a cgi script with the client's remote address using php...
> which means I am trying to trick the cgi script into thinking that the
> client is the one who requested the cgi script.


If you just need to make a simple HTTP GET request, that's built into PHP:

$php_results = file_get_contents( 'http://google.com/search?q=php' );

If you need to do POST or set custom headers like a Cookie or
User-Agent value, you will probably want to use the fsockopen()
approach proposed by Nasir Zubair. That will also let you set a
reasonable timeout ( 5 seconds or less ) in case the remote side is
not responding.


-- 
Chris Snyder
http://chxo.com/



More information about the talk mailing list