curl_unescape

Decodes the given URL encoded string

Syntax

curl_unescape ( resource $ch , string $str ) : string

Parameters

ch

A cURL handle returned by curl_init().

str

The URL encoded string to be decoded.

Return

Returns decoded string or FALSE on failure.

Examples

<?

$ch = curl_init();

    $curl_escapestr = 'Hofbräuhaus / München';

    $curl_escapereturn = curl_escape($ch, $curl_escapestr);

    curl_setopt($ch, CURLOPT_URL, "https://www.php.net?location=$curl_escapereturn");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

    curl_exec($ch);

    $str = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);

    $return = curl_unescape($ch, $str);

curl_close($ch);

echo $curl_escapestr . PHP_EOL;
echo $curl_escapereturn . PHP_EOL;
echo $str . PHP_EOL;
echo $return;

?>
Hofbräuhaus / München
Hofbr%C3%A4uhaus%20%2F%20M%C3%BCnchen
https://www.php.net?location=Hofbr%C3%A4uhaus%20%2F%20M%C3%BCnchen
https://www.php.net?location=Hofbräuhaus / München

PHP

Home Menu