I have the following URL: $url = 'http://mysite.com/?p=welcome&x=1&y=2';
I need to decode it so that header("Location: $url");
actually works.
However, using urldecode($url)
is not working because it's not decoding the &
-> &
and so the browser is getting redirected to http://mysite.com/?p=welcome&x=1&y=2
which fails.
I need it to decode so that it looks like: http://mysite.com/?p=welcome&x=1&y=2
How do I do that?
Try with htmlspecialchars_decode
echo htmlspecialchars_decode('http://mysite.com/?p=welcome&x=1&y=2');
//"http://mysite.com/?p=welcome&x=1&y=2"