简体   繁体   中英

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

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

Note that stripslashes only remove backslashes not forward

Or

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

Output

hello its a testing string

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

试试这个,使用\\/

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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