PHP 8.3.4 Released!

curl_multi_remove_handle

(PHP 5, PHP 7, PHP 8)

curl_multi_remove_handlecURL ハンドルのセットからマルチハンドルを削除する

説明

curl_multi_remove_handle(CurlMultiHandle $multi_handle, CurlHandle $handle): int

指定した handle を、multi_handle から削除します。 handle が削除されてからも、このハンドルで curl_exec() を実行できます。 使用中の handle を削除する際には、 そのハンドルにかかわる進行中の転送をきちんと停止します。

パラメータ

multi_handle

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

handle

curl_init() が返す cURL ハンドル。

戻り値

成功した場合に 0、失敗した場合にエラーコード CURLM_XXX のいずれかを返します。 codes.

変更履歴

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

参考

add a note

User Contributed Notes 1 note

up
5
mercury at caucasus dot net
13 years ago
It is always a good idea to use curl_close() on all individual curl handles after executing curl_multi_remove_handle(). This will free up additional memory resources. So, a typical code would look like:

<?php
$ch1
= curl_init();
curl_setopt($ch1, CURLOPT_URL, 'http://www.example.com/');
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);

$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, 'http://www.example.net/');
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);

$mh = curl_multi_init();

curl_multi_add_handle($mh, $ch1);
curl_multi_add_handle($mh, $ch2);

$active = null;

do {
curl_multi_exec($mh, $active);
}
while(
$active);

$res1 = curl_multi_getcontent($ch1);
$res2 = curl_multi_getcontent($ch2);

curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);

curl_multi_close($mh);

curl_close($ch1);
curl_close($ch2);
?>
To Top