How can I convert spaces in string into %20
?
Here is my attempt:
$str = "What happens here?";
echo urlencode($str);
The output is "What+happens+here%3F"
, so the spaces are not represented as %20
.
What am I doing wrong?
Use the rawurlencode
function instead.