This function has no effect. Prior to PHP 8.0.0, this function was used to close the resource.
とあるのでPHP8以降であれば呼んでも呼ばなくても変わらなさそうです。
Like!
phpではcurl_init
でcURL セッションを初期化しcurl_close
でcURL セッションを終了しているのですが、curl_close
を明示的に呼ばない場合の挙動はどうなっているのでしょうか?
例)
cURL関数を用いてAPIを叩いていいるのですが、curl_close
をする前にcurl_getinfo
でhttp_codeが200以外の時に処理を止めています。
200番台以外の時はcurl_close
が呼ばれていないのですが、処理は通常に動作します。。
curl_close
を明示的に呼ばない場合の挙動はどうなっているのでしょうか?
$curl = curl_init();
// ...[略]...
$curl_info = curl_getinfo($curl);
if ($curl_info['http_code'] !== 200) return;
// ...[略]...
curl_close($curl);
This function has no effect. Prior to PHP 8.0.0, this function was used to close the resource.
とあるのでPHP8以降であれば呼んでも呼ばなくても変わらなさそうです。
@tetsunari
Questioner