PHP | urldecode() Function

Last Updated : 11 Jul, 2025

The urldecode() function is an inbuilt function in PHP which is used to decode url that is encoded by the encode () function.

Syntax:

string urldecode( $input )

Parameters:

This function accepts a 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

// PHP program to illustrate urldecode function

// all sub domain  of geeksforgeeks
echo urldecode("https%3A%2F%2Fpractice.geeksforgeeks.org%2F"). "\n";
echo urldecode("https%3A%2F%2Fgeeksforgeeks.org%2F"). "\n";
?>

Output
https://www.geeksforgeeks.org/
https://www.geeksforgeeks.org/

Program 2 :

php
<?php

// all sub domain  of geeksforgeeks
$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");
    }
?>

Output
https://www.geeksforgeeks.org/
https://www.geeksforgeeks.org/
Comment