简体   繁体   English

str_replace('\\“','',$ str)不在服务器上工作原因?

[英]str_replace('\"','',$str) not working on server why?

I am using 我在用

str_replace('\"','',$str); 

to replace the '\\"' from php script. Its correctly working on localhost . 从php脚本中替换'\\"' 。它正确地在localhost工作。

When uploading its not working on server. 上传其无法在服务器上工作时。 Why ? 为什么?

The script is like, $str=http://www.keralatourism.org/beta-images/Newsletter.jpg\\""> To remove the \\" using echo str_replace('\\"','',$str); 脚本就像是,$ str = http://www.keralatourism.org/beta-images/Newsletter.jpg \\“”>删除\\“使用echo str_replace('\\”','',$ str);

Its working on local host but not in live server 它在本地主机上工作,但不在实时服务器上工作

the double quote does not need to be escaped unless it's wrapped in double quotes. 双引号不需要转义,除非它用双引号括起来。 str_replace('"','',$str); or str_replace("\\"",'',$str); str_replace('"','',$str);str_replace("\\"",'',$str);

if you want to find the back slash as well I believe you would have to escape it with another back slash. 如果你想找到反斜杠,我相信你将不得不用另一个反斜线逃脱它。

str_replace('\\\\"','',$str); or str_replace("\\\\"",'',$str); str_replace('\\\\"','',$str);str_replace("\\\\"",'',$str);

if you want to find " 如果你想找到" instead of " then you need to change the " " to " PHP sees these as different. 而不是"然后你需要改变" “到" PHP认为这些不同。

I am not completely clear but if you want to remove backslashes just user stripslashes 我不是很清楚,但如果你想删除反斜杠只是用户stripslashes

 $str= 'http://www.keralatourism.org/beta-images/Newsletter.jpg\""';
 echo stripslashes($str);

If you are trying to remove the double quotes: 如果您要删除双引号:

$str= 'http://www.keralatourism.org/beta-images/Newsletter.jpg\""';
echo str_replace ('"', '', $str);

Wrap the double quotes inside single quotes. 用单引号括起双引号。

Hope this helps you :) 希望这可以帮助你:)

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

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