Portal Home > Knowledgebase > Articles Database > [PHP] Passing a URL through a URL


[PHP] Passing a URL through a URL




Posted by krissauquillo, 12-06-2007, 09:45 PM
I can't seem to find a solution to this, so I was hoping someone here would know.. The problem is when I use: http://domain.com/?link=http://test.net/?a=1&b=2 And then use $_GET['link'] to retrieve the variable in PHP, I get: http://domain.com/?link=http://test.net/?a=1 The ampersand (&) is being parsed as a cut-off mark. Anyone know how I can fix it?

Posted by Annex, 12-06-2007, 09:56 PM
Just use the hexadecimal notation for the amprisan, which is %26 so your link would be http://domain.com/?link=http://test....=1%26b=2%26c=3 The browser will parse the %26 as an amprisan, only difficulty is replacing all links.

Posted by foobic, 12-06-2007, 09:58 PM
http://au.php.net/manual/en/function.urlencode.php

Posted by Codebird, 12-08-2007, 11:32 AM
use the %26 and then str_replace("%26", "&", $_GET['link']);

Posted by Harzem, 12-08-2007, 11:35 AM
It is called "urlencode", as foobic said.

Posted by Czaries, 12-11-2007, 02:53 PM
Yes, just use the built-in "urlencode" function... No sense in creating your own function that will run slower than native C code.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read


Language: