Jump to content

help getting parameters correctly from url


blic

Recommended Posts

Hi all,

 

I need to get a parameter from an url, but the GET variables are passed through urldecode().

Some of my variables may have characters such as "+", ":", spaces, etc.

When I use GET, all "+" are converted to spaces. I can use urlencode to get the "+" back, but also everything that was previously a space also turns into "+".

Example:

variable = abc+ c+:D

 

Then I can get either:

abc c :D

or

abc++c+:D

 

but I want to get abc+ c+:D

 

 

Would anybody know how to help me?

 

Thanks!

Or alternately can use

http://us.php.net/rawurldecode

and

http://php.net/manual/en/function.rawurlencode.php

 

example:

<?php
$url = "http://somesite.com/My File/script.php?value=1+2+3+4";
$decode = rawurldecode($url);
$encode = rawurlencode($decode);

echo $url."<br />";
echo $decode."<br />";
echo $encode."<br />";
?>

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.