Menu Home

curl_escape

osbo.com | PHP | Functions | curl_escape

URL encodes the given string

Syntax

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

Parameters

ch

A cURL handle returned by curl_init().

str

The string to be encoded.

Return

Returns escaped string or FALSE on failure.

Examples

<?

$ch = curl_init();

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

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

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

    curl_exec($ch);

curl_close($ch);

echo $str . PHP_EOL;
echo $return;

?>
Hofbräuhaus / München
Hofbr%C3%A4uhaus%20%2F%20M%C3%BCnchen

PHP