开发者

HTML characters in mail php

开发者 https://www.devze.com 2023-03-27 10:39 出处:网络
<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
<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

0

精彩评论

暂无评论...
验证码 换一张
取 消