Forum Moderators: coopster
$_GET['any-text']
would contain
"the-text"
if URL is:
http://example.com/?any-text=the-text
use LWP::Simple;
my $result = get("http://example.com/");
if (defined $result) {
# It worked, the content of the page is in $result.
print $result;
}
else {
print "Error with request.\n";
}
I don't know of a way that's as simple as that in PHP, but you can use the Curl library to do that sort of thing. The php.net docs for that are here, with some examples:
[php.net ]
Although by default it just dumps the downloaded data onto your output. You can redirect it to a file, and there must be a way to download it into a variable. Haven't tried that yet though.
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://www.example.com/');
curl_setopt ($ch, CURLOPT_HTTPHEADER, array('Cache-Control: no-cache', 'Host: www.example.com', 'Connection: close'));
curl_setopt ($ch, CURLOPT_USERAGENT, 'Hungry spider');
curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
$lines = curl_exec ($ch);
curl_close ($ch);