curl_multi_close

(PHP 5, PHP 7, PHP 8)

curl_multi_closecURL ハンドルのセットを閉じる

説明

curl_multi_close(CurlMultiHandle $multi_handle): void

注意:

この関数を実行しても何も起こりません。PHP 8.0.0 より前のバージョンでは、この関数はリソースを閉じるのに使われていました。

cURL ハンドルのセットを閉じます。

パラメータ

multi_handle

curl_multi_init() が返す cURL マルチハンドル。

戻り値

値を返しません。

変更履歴

バージョン 説明
8.0.0 multi_handleCurlMultiHandle クラスのインスタンスを期待するようになりました。 これより前のバージョンでは、resource を期待していました。

例1 curl_multi_close() の例

この例は、ふたつの cURL ハンドルを作成し、それをマルチハンドルに追加して非同期で実行します。

<?php
// cURL リソースを作成します
$ch1 = curl_init();
$ch2 = curl_init();

// URL およびその他適切なオプションを設定します。
curl_setopt($ch1, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/");
curl_setopt($ch2, CURLOPT_HEADER, 0);

// マルチ cURL ハンドルを作成します
$mh = curl_multi_init();

// ふたつのハンドルを追加します
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);

// ハンドルを実行します
do {
$status = curl_multi_exec($mh, $active);
if (
$active) {
curl_multi_select($mh);
}
} while (
$active && $status == CURLM_OK);

// ハンドルを閉じます
curl_multi_remove_handle($mh, $ch1);
curl_close($ch1);
curl_multi_remove_handle($mh, $ch2);
curl_close($ch2);
curl_multi_close($mh);

?>

参考

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top