Str_replace特殊字符邮件模板

时间:2017-06-02 01:32:23

标签: php

我有一个电子邮件模板,但我想要从textarea替换亲爱的文本。 我使用str_replace编辑文本。

如果使用此代码和内容有字符

'结果为\'

$html =str_replace('{{dear}}',$content,$html);

如果使用代码

$html =str_replace(array('\'', "'"), '', $html);

导致所有图片网址错误。

1 个答案:

答案 0 :(得分:2)

使用stripslashes功能和$html =str_replace("'", '', $html);

<强> PS

或在您的代码中使用以下行。

$html =str_replace(array("\'", "'"), array('',''), $html);
相关问题