从 PHP urldecoded 字符串中删除所有反斜杠 [英] Remove all backslashes from PHP urldecoded string
本文介绍了从 PHP urldecoded 字符串中删除所有反斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图从 url 解码的字符串中删除所有反斜杠,但它正在输出 \ 而不是输出带有 \ 的 url 解码字符串.
I am trying to remove all backslashes from a url-decoded string, but it is outputting \ rather than outputting the url-decoded string with \ removed.
请你告诉我我的问题.
<?php
$json = $_GET['ingredients'];
echo urldecode(str_replace($json,$json, "\\"));
?>
推荐答案
您想使用 stripslashes()代码>
,因为这正是它的用途.看起来也更短:
You want to use stripslashes()
, because that's exactly what it is for. Also looks shorter:
echo urldecode(stripslashes($json));
然而,您应该考虑禁用magic_quotes.
这篇关于从 PHP urldecoded 字符串中删除所有反斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文