I’m trying to put a script together for a client that needs to be able to accept a web address in a query string without it first being urlencoded. An example would be like this:
However, when I echo out the contents of $_GET[‘url’] it gives me the following:
http://www.amazon.co.uk/ESET-Smart-Security-User-Year/dp/B005NPFOBM/ref=sr_1_1?s=software
So basically it seems to choke on the first ampersand – i’m guessing because it thinks that its another variable.
Aside form urlencoding, are there any tricks to getting this working? I could probably POST it from a form, but this defeats the idea of the script.
For this specific use case, you should use
$_SERVER['QUERY_STRING']instead. This will give you the full query string in one go, you can then split it yourself.In your example, PHP is assuming that the & is the delimiter for the next GET variable.