从 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.