I am having a string United States
and i need to use this like United%20States
. For this i am using urlencode("United States");
But, it is giving me the result as United+States
. Please help me in getting me my output as United%20States
Thanks!
You can use rawurlencode
in this case (http://php.net/manual/en/function.rawurlencode.php)
You can use rawurlencode to achieve it- http://php.net/manual/en/function.rawurlencode.php
You want rawurlencode
, which
Encodes the given string according to » RFC 3986.
Note that urlencode
says:
This differs from the » RFC 3986 encoding (see rawurlencode()) in that for historical reasons, spaces are encoded as plus (+) signs.
See also:
Try using rawurlencode Refer: http://us2.php.net/manual/en/function.rawurlencode.php
Use this instead
<?php echo rawurlencode("United States"); ?>
<?php // str_rot13() example $string = 'Encoding and Decoding Encrypted PHP Code'; $encoded = str_rot13($string); $decoded = str_rot13(str_rot13($string)); echo $encoded ." "; echo $decoded; ?>