Tool for returning decoded URL using urldecode() in PHP

Once some URL is encoded, it has to be decoded when sending to output. Encoding and decoding are often used when storing URL’s in databases for further purposes (analysing content of certain web documents), or when linking to other web documents, therefore functions urlencode() and urldecode() always come together, but not in the same stage. Symbols that are encoded include question mark, percent, etc.

urldecode is a PHP function which converts any %## encoding and turns plus symbols into spaces.

 

Code example

<?php //returns urldecode of a string $str[] = "http%3A%2F%2Fwww.bing.com%2Fsearch%3Fq%3Djan%2Bhvizdak
%26qs%3Dn%26form%3DQBLH%26pq%3Djan%2Bhvizdak
%26sc%3D0-0%26sp%3D-1%26sk%3D"; echo "Output is: ".htmlspecialchars(urldecode($str[0])); /* http://www.bing.com/search?q=jan hvizdak
&qs=n&form=QBLH&pq=jan hvizdak
&sc=0-0&sp=-1&sk= */ ?>

Other tools & help

If you need help with PHP scripting, Apache setup and server-related situations, drop me a line. You’re also welcome to visit other tools - they’re listed below.