Hi,

This is my URL index.php?name=BSC&Subject=C++ When I do echo $_GET["Subject"]; , result is C without ++

I also tried (string) and settype() functions but no luck


How do I solve this problem?

Thanks

Recommended Answers

All 8 Replies

Using urlencode() may solve the problem, but the thing is that plus and space signs in URL have the same value, they are not recomeded to use at all in URLs.

Using urlencode() may solve the problem, but the thing is that plus and space signs in URL have the same value, they are not recomeded to use at all in URLs.

urlencode will convert them so they are fine and feel free to use them. space becomes %20, etc

A small remark - the space is converted to plus, not %20.

:)

hope it worked for ya

Member Avatar for diafol

Seems to work fine for me. I built this quick test:

<?php 
if(isset($_GET['q'])){
  echo "GET variable spits out: {$_GET['q']}";  
}
$q = urlencode('fdy+ +');
?>
<a href="?q=<?php echo $q;?>">hello</a>

True enough - space becomes '+' - but only after encoding.
Plus symbol is changed to '%2B'. Straightforward (*I think*).

ya it is +, but urlendcode is definitely the way to go

urlencode() is very simple solution. I liked it.
Thanks for other contributors though.

commented: kudos on the follow up :D +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.