urldecode() PHP Function Example

urldecode() PHP Function Example

PHP urldecode() Function Example. In this tutorial, we would love to share with you, how to decode given_url in PHP using the PHP urldecode() function with examples.

This tutorial has the purpose to show an easy way to decode a given URL in PHP. and Also this tutorial demonstrate to you PHP urldecode() function, definition, syntax, parameters with examples.

PHP – urldecode() Function

Definition:- The PHP urldecode() is an inbuilt function in PHP. That is used to decode the given URL. It will return an decoded string on success.


The basic syntax of php urldecode() function is following:

urldecode( $given_url )

Parameters of urldecode() function

This function accepts only one parameter, that is $given_url.

Example urldecode function

Let’s take the first example of PHP decode URL. Here we have one encoded url like “https%3A%2F%2Fwww.tutsmake.com”, and we will decode using the PHP urldecode() function.


// PHP script to decode given url using urldecode() function 
$givenUrl = " https%3A%2F%2Fwww.tutsmake.com ";
echo urldecode("$givenUrl") . "\n"; 


The output of the above PHP script is following:


Example 2 of PHP decode Urls

Let’s take the second example of PHP decode URL. Here we have multiple encoded URLs, and we will decode using the PHP urldecode() function.


// PHP script to decode, given urls using urldecode function php

echo urldecode("https%3A%2F%2Fwww.tutsmake.com") . "<br>"; 
echo urldecode("https%3A%2F%2Fwww.tutsmake.com%2Fword-character-counter-online-tool%2F
") . "<br>"; 
echo urldecode("https%3A%2F%2Fwww.tutsmake.com%2Fsubmit-tech-guest-post-write-for-us%2F") . "<br>"; 


The output of the above PHP script is the following:


Recommended PHP Tutorials

  1. Switch Statement in PHP | Decision-Making Statements
  2. PHP empty() – Check Variable is Empty in PHP
  3. isset() and unset() Function In PHP – Examples
  4. PHP Convert String to Array PHP
  5. jQuery AJAX Form Submit PHP MySQL
  6. PHP Sending Email (text/html)|PHP Mail() Function
  7. PHP Array: Indexed,Associative, Multidimensional
  8. PHP 7 File Upload | PHP Tutorial
  9. Create & Drop Database MySQL Using Command Line & PHP
  10. Connect MySQL Database to Command-Line OR PHP Script
  11. String functions in PHP – Strrev, strlen, implode, trim
  12. Array Functions In PHP – PHP Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *