PHP rawurldecode() Function
Quick summary: The PHP rawurldecode() function decodes a URL-encoded string encoded with rawurlencode().
PHP rawurldecode() Syntax
rawurldecode(string $string): string
PHP
PHP rawurldecode() Basic examples
var_dump(rawurldecode('hello%20world'));
PHP
Output:
string(11) "hello world"
Decodes %20 back into spaces.
PHP rawurldecode() Real-world usage
$path = 'images%2Fphoto%201.jpg';
var_dump(rawurldecode($path));
PHP
Output:
string(18) "images/photo 1.jpg"
Decodes URL-encoded file paths.
PHP rawurldecode() Edge cases
var_dump(rawurldecode('%ZZ'));
PHP
Output:
string(3) "%ZZ"
Invalid sequences are left unchanged.
PHP rawurldecode() Common mistakes
Decoding urlencode output
rawurldecode expects %20, not +.
Incorrect
rawurldecode('hello+world');
Correct
urldecode('hello+world');
Match rawurlencode with rawurldecode.
PHP rawurldecode() Frequently Asked Questions
What does rawurldecode() do?
Decodes a rawurlencoded string.
Difference from urldecode()?
Does not convert + to space.
Use case?
Decoding URL paths.
Is it reversible?
Yes with rawurlencode().
Handles UTF-8?
Yes.
Does it modify string?
No.
Common mistake?
Mixing with urlencode.
Performance?
Fast.
Used in REST APIs?
Yes.
Can decode full URL?
Yes.
Safe?
Yes.
Alternative?
urldecode().