Tutorialspoint.dev

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:

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

Output:



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

Program 2 :

<?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";
  
// craete an array 
$query = array($url1, $url2, $url3);
  
// print decoded url
foreach ($query as $chunk) {
        printf(urldecode($chunk). " ");
    }
?>

Output:

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

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



This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter