Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Decode the & from a URL so that header() works (urldecode not working)

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?

like image 529
ProgrammerGirl Avatar asked Jul 30 '12 14:07

ProgrammerGirl


People also ask

How do you decode messages?

Type or paste your coded message into the left box. Select the correct key numbers then press "Decode" to reveal the hidden message.

How do I decode a string?

So first, write the very first character of the encoded string and remove it from the encoded string then start adding the first character of the encoded string first to the left and then to the right of the decoded string and do this task repeatedly till the encoded string becomes empty.

What is decode the message?

The decoding of a message is how an audience member is able to understand, and interpret the message. It is a process of interpretation and translation of coded information into a comprehensible form.


1 Answers

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"
like image 167
Esailija Avatar answered Oct 04 '22 00:10

Esailija