user5443928
user5443928

Reputation:

Can not get the special charcter from query string value using PHP

I need one help. I need to fetch all data from query string using PHP but some special charcters like (i.e-+,- etc) are not coming. I am explaining my code below.

http://localhost/test/getmethod.php?name=Goro + Gun

Here I need to get the value assign to name using the below code.

<?php
$name=$_GET['name'];
echo $name;
?> 

Here I am getting the output like Goro Gun but I need the original value i.e-Goro + Gun .Please help me to resolve this issue.

Upvotes: 1

Views: 42

Answers (2)

lazyCoder
lazyCoder

Reputation: 2561

@subhra try this for this case name=Goro + Gun:

<?php
$nameArr = explode('=', $_SERVER['QUERY_STRING']);
$name = str_replace("%20", " ", $nameArr[1]);
echo $name;
?>

Upvotes: 1

Skalbhile
Skalbhile

Reputation: 156

$_SERVER['QUERY_STRING'] - this will return you full query string

Upvotes: 0

Related Questions