繁体   English   中英

我如何在PHP中使用'\\'

[英]how can i use '\' in php

任何人都知道我可以使用

$utf8string = str_replace('\',"\",$utf8string);

在PHP中? 因为我不能在\\之后使用',这给我一个错误
如果我写

$utf8string = str_replace('\ ',"\",$utf8string);

它不做我想要的

$utf8string = str_replace("\","\",$utf8string);

也不行
那我该怎么办?
我想更新mysql,但是如果我的文本结尾有\\它不起作用,并给我一个错误
喜欢这个查询

update phpfox_comment_text set text_parsed = 'nakheir\',text = '' where comment_id = 197597

我想更新400.000个查询,但我必须用\\ cuz替换\\我总是收到此错误

尝试使用\\\\而不是\\

\\用于转义时在字符串中具有特殊含义。 意思是\\您需要将其转义! 在前面加上一个\\

逃离\\另一个\\

$utf8string = str_replace("\\","\",$utf8string);
$utf8string = str_replace('\\',"\",$utf8string);

“ \\”是“元字符”。

如果需要,可以使用"\\\\" “转义”它。

暂无
暂无

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

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