Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's wrong with putting spaces in $_GET variables

If I for example have my url looking like index.php?category=IT%20&%20Soft. Then i try to print "$_GET[category]" i only get "IT" and not "IT & Soft". What is wrong here? It's frustrating me.

like image 894
ionescho Avatar asked Jun 15 '11 21:06

ionescho


1 Answers

The problem is not the spaces, but the ampersand.

Use %26 instead, like this:

index.php?category=IT%20%26%20Soft

The ampersand indicates that you are beginning another field (like category=IT&subcategory=somethingelse). You can see a list of reserved characters on Wikipedia.

like image 143
Brad Avatar answered Oct 11 '22 14:10

Brad