get_resources

(PHP 7, PHP 8)

get_resourcesアクティブなリソースを返す

説明

get_resources(string|null $type = null): array

現在アクティブなすべてのリソースの配列を返します。 オプションでリソース型によってフィルタリングされます。

パラメータ

type

定義された場合、get_resources() は、指定された型のリソースのみを返すようになります。 リソース型の一覧が使用できます。

string Unknown が型として指定された場合、 不明な型のリソースのみが返されます。

省略した場合、すべてのリソースが返されます。

返り値

現在アクティブなリソースの array を返します。 リソース番号でインデックス付けされます。

変更履歴

バージョン 説明
8.0.0 type は、nullable になりました。

例1 フィルタリングされていない get_resources()

<?php
$fp 
tmpfile();
var_dump(get_resources());
?>

上の例の出力は、 たとえば以下のようになります。

array(1) {
  [1]=>
  resource(1) of type (stream)
}

例2 フィルタリングされた get_resources()

<?php
$fp 
tmpfile();
var_dump(get_resources('stream'));
var_dump(get_resources('curl'));
?>

上の例の出力は、 たとえば以下のようになります。

array(1) {
  [1]=>
  resource(1) of type (stream)
}
array(0) {
}

参考

add a note add a note

User Contributed Notes

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