YouTip LogoYouTip

Func Curl_Escape

PHP curl_escape Function |

-- Learning is not just about technology, but also about dreams!

PHP Tutorial

PHP Forms

PHP Advanced Tutorial

PHP 7 New Features

PHP Database

PHP XML

PHP and AJAX

PHP Reference Manual

PHP curl_error Function

PHP curl_exec Function

PHP curl_escape Function

PHP cURL Reference Manual PHP cURL Reference Manual

(PHP 5 >= 5.5.0)

curl_escape β€” URL-encodes the given string.


Description

string curl_escape ( resource $ch , string $str )

This function URL-encodes the given string according to Β» RFC 3986.


Parameters

ch

A cURL handle returned by curl_init().

str

The string to be encoded.


Return Values

Returns the encoded string, or FALSE on failure.


Example

<?php
// Create a cURL Handle
$ch = curl_init();

// Encode GET Parameters
$location = curl_escape($ch, 'HofbrΓ€uhaus / MΓΌnchen');
// Result: Hofbr%C3%A4uhaus%20%2F%20M%C3%BCnchen

// Compare the Encoded URL
$url = "http://example.com/add_location.php?location={$location}";
// Result: http://example.com/add_location.php?location=Hofbr%C3%A4uhaus%20%2F%20M%C3%BCnchen

// Send HTTP Request and Close Handle
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
?>

PHP cURL Reference Manual PHP cURL Reference Manual

← Func Curl_ExecFunc Curl_Error β†’