I’ve a Zend Framework URI like /controller/action/var1/value1/var2/value2 .
-
Value2 has a space character in it. How should I encode it in PHP? When I use urlencode with value2, this converts space into ‘+’ instead of ‘%20f’. Is that ok?
-
This value2 is also added to a href location by javascript on client side. I’m using escape function there but when I click link I neither see ‘+’ nor ‘%20f’ in firefox address bar. Though when I see it in firebug ‘net’ tab, I see %20f.
Which functions should I use in PHP and javascript?
About your first question, that is the difference between
urlencodeandrawurlencode:Will get you :
While
will get you :
I suppose both should be OK ; but feel free to give it a try, just in case 😉
About the second point : Firefox tries to make URLs “prettier”, displaying them in a human-readable way, instead of encoded — which is bad for us developpers, but nice to end-users.
For instance, if I type this URL in Firefox’s address bar :
When I press the enter key, it’s automatically translated to
If it works the way you are doing it (and, as you are seeing an encoded URL with Firebug, it’s probably working), everything’s OK 😉