PHP URL Decode example
1 minsPHP contains two inbuilt functions called urldecode()
and rawurldecode()
to decode a URL encoded string back to its normal form.
The urldecode() function
# Syntax
urldecode (string $str) : string
The urldecode()
function takes a URL encoded (percent encoded) string and decodes it. It is just the opposite of urlencode()
function. It converts plus sign (+
) to space character.
Example
<?php
echo urldecode("Hell%C3%B6+W%C3%B6rld") . "\n";
?>
# Output
Hellö Wörld
The rawurldecode() function
The rawurldecode()
function is just like urldecode()
function except that it doesn’t decode plus sign (+
) to space character -
# Syntax
rawurldecode (string $str) : string
Example
<?php
echo rawurldecode("Hell%C3%B6+W%C3%B6rld") . "\n";
?>
# Output
Hellö+Wörld
Also Read: URL Encode PHP Example