I have a value in variable as follows…
$variable = "chicken soup.jpg";
when i do the following, spaces are converted to a + symbol in the output
$body = "www.abc.com/" . $variable
mail($to, $subject, $body,$headers)
Output in mail received: http://www.abc.com/chicken+soup.jpg
But i want the output as below ? Please help
Expected Output : http://www.abc.com/chicken%20soup.jpg or
http://www.abc.com/chicken soup.jpg
i tried using str_replace function but no luck
I’m pretty sure, if your email-client supports to view the plain source of that message, you’ll se that the url is
"www.abc.com/chicken soup.jpg"; only your browser / email client encodes it, as it’s an invalid URL.If you want to produce a valid url, encode it manually with:
or:
Edit:
You can read more about the difference:
rawurlencode())application/x-www-form-urlencoded(or form post) encoding (urlencode())