CancelImage Upload

Replacing %3A, %2F & %3D with slashes, question marks, etc inside URLs in PHP

When passing along a URL as a Get variable, certain symbols need to be converted into a percentage sign, and a two digit hexadecimal equivalent of the corresponding ASCII symbol.

Therefore a colon turns into %3A, slashes are converted into %2F, question marks become %3F and equals becomes %3D. As a result the URL would end up looking something like this:

While a URL in this format will do well as a Get variable, it will not be much use to us as a url in it's current format. Clearly some decoding work is needed. And this can be gone about in two ways. Method number one: put together a regular expression or a few lines of str_replace(). Method number two: use the predefined PHP function rawurldecode(), save a lot of time, and go chilax. I know which method I would prefer:


$raw_url = "";

$decoded_url = rawurldecode($raw_url);

echo $decoded_url;


Want to leave a comment?

No problem. Just enter your email and password below.

register | home | reminder

myDesignTool Networking •