PHP: convert spaces in string into %20?
Use the rawurlencode
function instead.
The plus sign is the historic encoding for a space character in URL parameters, as documented in the help for the urlencode()
function.
That same page contains the answer you need - use rawurlencode()
instead to get RFC 3986 compatible encoding.
I believe that, if you need to use the %20
variant, you could perhaps use rawurlencode()
.