curl_init

(PHP 4 >= 4.0.2, PHP 5, PHP 7, PHP 8)

curl_initBir cURL oturumunu ilklendirir

Açıklama

curl_init(?string $url = null): CurlHandle|false

Yeni bir oturumu ilklendirip curl_setopt(), curl_exec() ve curl_close() işlevleriyle kullanmak için bir cURL tanıtıcısı döndürür.

Bağımsız Değişkenler

url

Belirtilmişse, değer CURLOPT_URL seçeneğine atanır. Bu seçeneğe curl_setopt() işleviyle de değer atayabilirsiniz.

Bilginize:

open_basedir etkin kılınırsa file protokolü cURL tarafından iptal edilir.

Dönen Değerler

Başarı durumunda bir cURL tanıtıcısı yoksa false döner.

Sürüm Bilgisi

Sürüm: Açıklama
8.0.0 Başarı durumunda bu işlev artık bir CurlHandle örneği döndürüyor; evvelvce resource türünde bir değer dönerdi.
8.0.0 url artık null olabiliyor.

Örnekler

Örnek 1 - Yeni bir cURL oturumunun ilklendirilmesi ve bir HTML sayfasının alınması

<?php
// Yeni bir cURL özkaynağı oluşturalım
$ct = curl_init();

// URL'yi ve ilgili seçenekleri belirtelim
curl_setopt($ct, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ct, CURLOPT_HEADER, 0);

// URL'yi tarayıcıya aktaralım
curl_exec($ct);

// cURL özkaynağını kapatıp sistem özkaynaklarını serbest bırakalım
curl_close($ct);
?>

Ayrıca Bakınız

add a note add a note

User Contributed Notes 1 note

up
0
webmaster at jamescobban dot net
3 years ago
On recent distributions CURL and PHP support for CURL have not been included in the main product.  In particular in recent distributions of Ubuntu Linux CURL and PHP support for CURL are not even available from the official repositories.  The steps to incorporate support are complex and require adding a non-standard repository.  It is therefore advisable for programmers to rewrite code to use the stream interface to access resources across the Internet.  For example:

```php
$opts = array(
        'http' => array (
            'method'=>"POST",
            'header'=>
              "Accept-language: en\r\n".
              "Content-type: application/x-www-form-urlencoded\r\n",
            'content'=>http_build_query(array('foo'=>'bar'))
  )
);

$context = stream_context_create($opts);

$fp = fopen('https://www.example.com', 'r', false, $context);

```

This stream support can also be accessed using the object-oriented interface of SplFileObject.
To Top