从PHP urldecoded字符串中删除所有反斜杠

max*_*ax_ 6 php urldecode str-replace

我试图从URL解码的字符串中删除所有反斜杠,但它输出\而不是输出已删除的url解码字符串.

请你告诉我我的问题.

<?php
$json = $_GET['ingredients'];
echo urldecode(str_replace($json,$json, "\\"));
?>
Run Code Online (Sandbox Code Playgroud)

mar*_*rio 13

你想使用stripslashes(),因为它正是它的用途.看起来也更短:

echo urldecode(stripslashes($json));
Run Code Online (Sandbox Code Playgroud)

但是你应该考虑禁用magic_quotes.