简体   繁体   English

如何在PHP中str_replace \\符号

[英]How to str_replace \ symbol in php

I have a string containing '\\' in it but when i replaced the string with blank it showing error. 我有一个包含'\\'的字符串,但是当我用空白替换该字符串时,它显示错误。

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

Thank you all 谢谢你们

干得好:

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

Try stripslashes for this 尝试stripslashes

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

Note that stripslashes only remove backslashes not forward 需要注意的是stripslashes只删除backslashes不转发

Or 要么

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

Output 输出量

hello its a testing string

转义反斜杠,以便... \\\\

试试这个,使用\\/

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM