PHP | rawurldecode() function

The rawurldecode() function is an inbuilt function in PHP which is used to decode the encoded string. This function returns the decoded URL (original URL string) as a string. This function replaces the % sign followed by two hex value with literal characters.

Syntax:

string rawurldecode( $str )

Parameters: This function accepts single parameters $str which is mandatory. It is used to store the encoded URL.



Return Value: This function returns the decode URL string.

Below programs illustrate the rawurldecode() function in PHP.

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
    echo rawurldecode("A%20computer%20science%20portal%20for%20geek");
?>

chevron_right


Output:

A computer science portal for geek

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?PHP
$str = 'GeeksforGeeks A computer science portal for geek'
  
// Encode the given string
$encode_str = rawurlencode($str); 
echo "Encoded string: " . $encode_str . "<br>";
  
// Decode the encoded string
$decode_str = rawurldecode($encode_str); 
echo "Decodec string: " . $decode_str;
?>

chevron_right


Output:

Encoded string: GeeksforGeeks%20A%20computer%20science%20portal%20for%20geek
Decodec string: GeeksforGeeks A computer science portal for geek

Related Articles:

Reference: http://php.net/manual/en/function.rawurldecode.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.


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.