如何取代“ 进入“使用php字符串函数

This is a simple issue but I have been unable to solve this. My problem is that I am sending email using the libmail class.

$message = htmlspecialchars(stripslashes(strip_tags($message)));

Everything is working fine but if I use the " in the text, it will be diaslayed in the mail as ". I have already tried:

mail ($strTo, $this->xheaders['Subject'], htmlentities($this->fullBody), $this->headers,"-f $rtpth");

How to solve this?

If you're using a recent version of PHP (v5.1 or better), you can use htmlspecialchars_decode to .. uh... decode htmlspecialchars.

See here for the manual page: http://php.net/manual/en/function.htmlspecialchars-decode.php

Leave out the htmlspecialchars and htmlentites calls, they are converting your quotes to html entites, which means that your " character is converted to & quot;

You don't need to use htmlspecialchars when defining $message

By the way, for decoding html entities - http://lv.php.net/manual/en/function.html-entity-decode.php

set ENT_NOQUOTES, " should then not be replaced htmlspecialchars($string,ENT_NOQUOTES)http://php.net/manual/de/function.htmlspecialchars.php