get_resource_id

Returns an integer identifier for the given resource

Syntax

get_resource_id ( resource $res ) : int

Parameters

res

The evaluated resource handle.

Return

The int identifier for the given res.

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

Examples

1

<?

$filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/txt/file.txt";
$mode = "r";

$handle = fopen($filename, $mode);

    $return = get_resource_id($handle);

    echo $return;

fclose($handle);

?>
3

2

<?

$filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/txt/file.txt";
$mode = "r";

$handle = fopen($filename, $mode);

    echo (int)$handle;

fclose($handle);

?>
3
HomeMenu