Page 1 of 1

$_GET Help

Posted: Wed Dec 07, 2011 3:16 pm
by HB-Dave
How do I grab a get variable where the value of the variable may have an "&" sign in it?

For example, for this URL

Code: Select all

//http://example.com/?site=http://www.youtube.com/watch?v=S8zhmiS-1kw&ThisGets=CutOff

echo $_GET["site"];

//returns "http://www.youtube.com/watch?v=S8zhmiS-1kw"
//This, "&ThisGets=CutOff" because of the "&"

//How do I make $_GET["site"]== http://www.youtube.com/watch?v=S8zhmiS-1kw&ThisGets=CutOff

Re: $_GET Help

Posted: Wed Dec 07, 2011 3:22 pm
by twinedev
The problem is the URL is not properly formatted for the purpose you are wanting to use here.

$_GET['site'] = 'http://www.youtube.com/watch?v=S8zhmiS-1kw'
and
$_GET['ThisGets']='CutOff';

Whatever is making the link that you gave, it needs urlencode() around the url:

Code: Select all

echo '<a href="http://example.com/?site=' . urlencode($site2pass) .'">Link Text</a>';
see http://php.net/urlencode

-Greg

Re: $_GET Help

Posted: Wed Dec 07, 2011 3:32 pm
by HB-Dave
Great, that looks like it should work. Thanks for your help!