The Wayback Machine - https://web.archive.org/web/20231211192709/https://www.geeksforgeeks.org/php-rawurldecode-function/
Open In App
Related Articles

PHP | rawurldecode() function

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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:




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


Output:

A computer science portal for geek

Program 2:




<?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 "Decoded string: " . $decode_str;
?>


Output:

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

Related Articles:

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

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 09 Nov, 2022
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials