2016-09-08 33 views
0

我有一個字符串包含'\',但是當我用空白 替換字符串時顯示錯誤。如何在php中str_replace 符號

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

謝謝大家

+0

什麼是您的電子郵件b ody,請你把它放在這裏,你想要什麼? – rahul

+0

請提供更多的上下文,提供[最小的,完整的可驗證的示例](http://stackoverflow.com/help/mcve)幫助我們爲您提供幫助。 – dubes

回答

1

嘗試stripslashes

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

注意stripslashes只刪除backslashes不轉發

或者

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

輸出

hello its a testing string 
0

讓您遠離反斜槓所以... \\

1

在這裏你去:

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

試試這個, 使用\/

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