How To Send A GET Request to HTTP using PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
receiver
Forum Newbie
Posts: 4
Joined: Tue May 19, 2009 10:18 pm

How To Send A GET Request to HTTP using PHP

Post by receiver »

As title mentioned,

for example, I want to send a get request to a permanent link(etc http://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.
Edit/Delete Message
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: How To Send A GET Request to HTTP using PHP

Post by jaoudestudios »

How do you want the result to be returned?
Use

Code: Select all

$page = file('www.google.com?a='.$a);
receiver
Forum Newbie
Posts: 4
Joined: Tue May 19, 2009 10:18 pm

Re: How To Send A GET Request to HTTP using PHP

Post by receiver »

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%2Bdatacenter@gmail.com")

it works on the second, however the first one is not working. I think is the +(%2B) sign. How can i solve it, so that the browser can interpret + as %2B?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: How To Send A GET Request to HTTP using PHP

Post by onion2k »

Get vars should be url encoded. Use urlencode()
Post Reply