My project Url is like this in yii:
http://localhost/php_pro_106/activate/Test?JJ=HEY+OOO
In my action :
public function actionTest()
{
print_r($_GET);
}
I am getting:
Array ( [JJ] => HEY OOO )
But I should get:
Array ( [JJ] => HEY+OOO )
What should I do for this,I need same Url ?
A +
in a URL means a space. So you get the result you should have.
If you want to encode a +
character in a URL, then you should represent it as %2B
.
http://localhost/php_pro_106/activate/Test?JJ=HEY%2BOOO
If you are generating the URL programatically with PHP, you can use the urlencode
function.
$keyname = "JJ";
$data = "HEY+OOO";
$url = "http://localhost/php_pro_106/activate/Test?" . urlencode($keyname) . "=" . urlencode($data);
You need to encode your URL (e.g. with urlencode
in php). +
needs to become %2B
.
http://localhost/php_pro_106/activate/Test?JJ=HEY%2BOOO
"+" is one of reserved characters, according to RFC 2396.
If you want "+" in your example, you should use url encoding.
http://localhost/php_pro_106/activate/Test?JJ=HEY%2BOOO
If you produce URL from code, use urlencode() function to generate your URLS.