HTML characters in mail php
<a href='http://stackoverflow.com' style='color:red;'>testing</a>
The above is my text inside textarea. I am passing this textarea value as a mail body. The word "testing" appears neither anchored nor red.
However, when I write this:
开发者_开发百科$body="<a href='http://stackoverflow.com' style='color:red;'>testing</a>";
..and pass $body
as my mail body, it works fine.
What could cause this behavior?
my first guess is that you have "Magic Quotes" option on in the php settings, and the mail body ends up like:
<a href=\'http://stackoverflow.com\' style=\'color:red;\'>testing</a>
Try to use "view source" on the recived mail, or use "save as" and open the file in a simple text editor, and you should se how the mail ended up.
if my guess was right, you could either turn of magic quets, or use stripslashes() to remove the extra slaches
精彩评论