get_resources()

get_resources() — Returns active resources.

Built-in function of PHP 8.5. The manual lists it as available in PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

Returns an array of all currently active resources, optionally filtered by resource type.

Signature

get_resources(?string $type = null): array

Parameters

ParameterTypeWhat it takes
$type?stringIf defined, this will cause get_resources() to only return resources of the given type. A list of resource types is available.

Return value

Returns an array of currently active resources, indexed by resource number.

Example

A runnable snippet:

$fp = tmpfile(); var_dump(get_resources());

Output:

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

Changelog

VersionChange
8.0.0type is nullable now.

See also

get_loaded_extensions(), get_defined_constants(), get_defined_functions(), get_defined_vars()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page get_resources() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.