cURL curl_share_init

(PHP 5 >= 5.5.0, PHP 7, PHP 8)

curl_share_init — cURL 공유 핸들 초기화


설명

curl_share_init(): CurlShareHandle

cURL 핸들 간에 데이터를 공유할 수 있습니다.


매개변수

이 함수에는 매개변수가 없습니다.


반환 값

cURL 공유 핸들을 반환합니다.


변경 로그

버전 설명
8.0.0 이 함수는 이제 CurlShareHandle 인스턴스를 예상합니다. 이전에는 리소스가 필요했습니다.

Examples

예제 #1 curl_share_init() 예제

이 예에서는 cURL 공유 핸들을 만들고 여기에 두 개의 cURL 핸들을 추가한 다음 쿠키 데이터 공유와 함께 실행합니다.

                  
<?php
// Create cURL share handle and set it to share cookie data
$sh = curl_share_init();
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);

// Initialize the first cURL handle and assign the share handle to it
$ch1 = curl_init("http://example.com/");
curl_setopt($ch1, CURLOPT_SHARE, $sh);

// Execute the first cURL handle
curl_exec($ch1);

// Initialize the second cURL handle and assign the share handle to it
$ch2 = curl_init("http://php.net/");
curl_setopt($ch2, CURLOPT_SHARE, $sh);

// Execute the second cURL handle
//  all cookies from $ch1 handle are shared with $ch2 handle
curl_exec($ch2);

// Close the cURL share handle
curl_share_close($sh);

// Close the cURL handles
curl_close($ch1);
curl_close($ch2);
?>
                  
                

기타