如何在php中str_replace \ symbol

时间:2016-09-08 06:23:01

标签: php str-replace

我有一个包含'\'的字符串,但是当我用空格替换字符串时 它显示错误。

$emailbody = str_replace('\','',$emailbody);

谢谢大家

4 个答案:

答案 0 :(得分:1)

你走了:

$emailbody = str_replace('\\', '', $emailbody);

答案 1 :(得分:1)

请尝试stripslashes

 $emailbody = "hello \ its a testing\ string";
 echo $emailbody = stripslashes($emailbody);

注意 stripslashes仅删除backslashes无法转发

echo $emailbody =  str_replace("\\","",$emailbody);

输出

hello its a testing string

答案 2 :(得分:0)

逃避反斜杠...... \\

答案 3 :(得分:0)

试试这个, 使用\/

$emailbody = str_replace('\/','',$emailbody);