PHP 8.1.28 Released!

get_resource_id

(PHP 8)

get_resource_id 返回给定资源的整数标识符

说明

get_resource_id(resource $resource): int

此函数提供了一种类型安全的方式来生成资源的整数标识符。

参数

resource

需要获取的资源句柄。

返回值

给定 resourceint 标识符。

此函数本质上是对 resourceint 转换,使得更容易获取资源的标识符。

示例

示例 #1 get_resource_id()int 转换的结果相同

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

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

echo
get_resource_id($handle);

?>

以上示例的输出类似于:

698
698

参见

add a note

User Contributed Notes

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