Jump to content

How To Send A GET Request to HTTP using PHP


receiver19

Recommended Posts

As title mentioned,

 

for example, I want to send a get request to a permanent link(etc www.google.com) using php, the outcome will become google.com?0=name?

 

form is not the proper step, as in i need to type in the name. How do i send a request to http using php?

 

Thanks.

http://us2.php.net/curl_exec

 

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "google.com?0=name");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curl_res = curl_exec($ch);
curl_close($ch);

 

results stored in $curl_res variable.

Thanks for the reply.

However,

 

1. curl_setopt($ch, CURLOPT_URL, "http://example.com?0=". $email ."")

2. curl_setopt($ch, CURLOPT_URL, "http://example.com?0=abc%[email protected]")

 

it works on the second, however the first one is not working. I think is the + sign. How can i solve it so that the browser interpret + as %2B?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.