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 w3wiki
echo urldecode("https%3A%2F%2Fide.w3wiki.net%2F"). "\n";
echo urldecode("https%3A%2F%2Fpractice.w3wiki.net%2F"). "\n";
echo urldecode("https%3A%2F%2Fw3wiki.net%2F"). "\n";
?>


Output:

https://ide.w3wiki.net/
https://practice.w3wiki.net/
https://w3wiki.net/

Program 2 :




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


Output:

https://ide.w3wiki.net/
https://practice.w3wiki.net/
https://w3wiki.net/

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



Contact Us