PHP get_resource_id() Function Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The get_resource_id() function is an inbuilt function in PHP that returns the integer id given resource. This function provides a safe way of generating integers for a resource. Syntax: get_resource_id($resource) ;Parameters: This function accepts one parameter that are described below: $resource: Name of the resource for which we want resource id.Return Value: This function returns the int identifier of the given resource. Example 1: In the below code example, we will print the id of the given resource. PHP <?php $res = tmpfile() ; // Print resource id of tmpfile echo get_resource_id($res); ?> Output: 4Example 2: In the below code example, we are opening a text file and then returning his resource id. It may be resource id will be different according to your computer. PHP <?php $res = fopen("text.txt", "rb"); echo get_resource_id($res); ?> Output: 5 Reference: https://www.php.net/manual/en/function.get-resource-id.php Comment N neeraj3304 Follow 0 Improve N neeraj3304 Follow 0 Improve Article Tags : PHP PHP-function Explore PHP Tutorial 8 min read BasicsPHP Syntax 4 min read PHP Variables 5 min read PHP | Functions 8 min read PHP Loops 4 min read ArrayPHP Arrays 5 min read PHP Associative Arrays 4 min read Multidimensional arrays in PHP 5 min read Sorting Arrays in PHP 4 min read OOPs & InterfacesPHP Classes 2 min read PHP | Constructors and Destructors 5 min read PHP Access Modifiers 4 min read Multiple Inheritance in PHP 4 min read MySQL DatabasePHP | MySQL Database Introduction 4 min read PHP Database connection 2 min read PHP | MySQL ( Creating Database ) 3 min read PHP | MySQL ( Creating Table ) 3 min read PHP AdvancePHP Superglobals 6 min read PHP | Regular Expressions 12 min read PHP Form Handling 4 min read PHP File Handling 4 min read PHP | Uploading File 3 min read PHP Cookies 9 min read PHP | Sessions 7 min read Like