php8.5
Home/ Manual/ var / functions/ get_resource_id

get_resource_id

PHP function Edit on GitHub ✎

(PHP 8)

Returns an integer identifier for the given resource

Description

get_resource_id(resource $resource): int

This function provides a type-safe way for generating the integer identifier for a resource.

Parameters

resource

The evaluated resource handle.

Return Values

The int identifier for the given resource.

This function is essentially an int cast of resource to make it easier to retrieve the resource ID.

Examples

get_resource_id() produces the same result as an int cast

php
<?php
$handle = fopen("php://stdout", "w");

echo (int) $handle . "\n";

echo get_resource_id($handle);

?>

The above example will output something similar to:

output
698
698

See Also

Source: reference/var/functions/get-resource-id.xml · from the official PHP manual (php/doc-en)