略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: get_resource_id

2024-12-22

get_resource_id

(PHP 8)

get_resource_id Returns an integer identifier for the given resource

说明

get_resource_id(resource $resource): int

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

参数

resource

The evaluated resource handle.

返回值

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.

范例

示例 #1 get_resource_id() produces the same result as an int cast

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

echo (int) 
$handle "\n";

echo 
get_resource_id($handle);

?>

以上例程的输出类似于:

698
698

参见

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/function.get-resource-id.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3