Pro*_*irl 12 php header decoding urldecode
我有以下网址: $url = 'http://mysite.com/?p=welcome&x=1&y=2';
我需要解码它以便header("Location: $url");实际工作.
但是,使用urldecode($url)不起作用,因为它没有解码&- > &因此浏览器被重定向到http://mysite.com/?p=welcome&x=1&y=2失败.
我需要它来解码,使它看起来像: http://mysite.com/?p=welcome&x=1&y=2
我怎么做?
Esa*_*ija 28
echo htmlspecialchars_decode('http://mysite.com/?p=welcome&x=1&y=2');
//"http://mysite.com/?p=welcome&x=1&y=2"
Run Code Online (Sandbox Code Playgroud)
&未进行 url 编码。您需要使用htmlspecialchars_decode() http://php.net/manual/en/function.htmlspecialchars-decode.php