PHP | urldecode() Function

The urldecode() function is an inbuilt function in PHP which is used to decode url which is encoded by encoded() function.
Syntax:

string urldecode( $input )

Parameters: This function accepts single parameter $input which holds the url to be decoded.

Return Value: This function returns the decoded string on success.

Below programs illustrate the urldecode() function in PHP:
Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// PHP program to illustrate urldecode function
  
// all sub domain  of geeksforgeeks
echo urldecode("https%3A%2F%2Fide.geeksforgeeks.org%2F"). "\n";
echo urldecode("https%3A%2F%2Fpractice.geeksforgeeks.org%2F"). "\n";
echo urldecode("https%3A%2F%2Fgeeksforgeeks.org%2F"). "\n";
?>

chevron_right


Output:

https://ide.geeksforgeeks.org/
https://practice.geeksforgeeks.org/
https://geeksforgeeks.org/

Program 2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// all sub domain  of geeksforgeeks
$url1 = "https%3A%2F%2Fide.geeksforgeeks.org%2F";
$url2 = "https%3A%2F%2Fpractice.geeksforgeeks.org%2F";
$url3 = "https%3A%2F%2Fgeeksforgeeks.org%2F";
  
// create an array 
$query = array($url1, $url2, $url3);
  
// print decoded url
foreach ($query as $chunk) {
        printf(urldecode($chunk). "\n");
    }
?>

chevron_right


Output:

https://ide.geeksforgeeks.org/
https://practice.geeksforgeeks.org/
https://geeksforgeeks.org/

Reference: http://php.net/manual/en/function.urldecode.php



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : nidhi_biet



Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.