PHP get_resources() Function Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The get_resources() function is an inbuilt function in PHP that returns active resources in an array form, & optionally, the resource type will be filtered. Syntax: array get_resources(?string $type = null)Parameters: This function accepts one parameter that is described below: type: This parameter will restrict the function to return only the resources for the given type if defined. If the string is unknown, it will return unknown resources. It will return all resources if this is omitted.Return Value: This function returns current resources in an array form, indexed by resource number. Example 1: In the below code, we will return specific resources using the get_resources() function. PHP <?php var_dump(get_resources('stream')) ; ?> Output: array(3) { [1]=> resource(1) of type (stream) [2]=> resource(2) of type (stream) [3]=> resource(3) of type (stream) } Example 2: This is another example that demonstrates the get_resources() function. PHP <?php $fp = tmpfile(); var_dump(get_resources()); ?> Output: array(4) { [1]=> resource(1) of type (stream) [2]=> resource(2) of type (stream) [3]=> resource(3) of type (stream) [4]=> resource(4) of type (stream) } Reference: https://www.php.net/manual/en/function.get-resources.php Comment More infoAdvertise with us Next Article PHP get_resources() Function neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-Options-info Similar Reads PHP get_resource_id() Function 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: 1 min read PHP get_resource_type() Function The get_resource_type() function is an inbuilt function in PHP that is used for returning the type of resource. Syntax: get_resource_type(resource $resource) Parameters: This function accepts one parameter that described below: $resource: This parameter specifies the evaluated resource handle name.R 1 min read PHP | show_source() Function The show_source() function is an inbuilt function in PHP which is used to return a file with the PHP syntax highlighted. The syntax is highlighted by using HTML tags. Syntax: show_source( $filename, $return ) Parameters: This function accepts two parameters as mentioned above and described below: $f 2 min read PHP | Imagick setResourceLimit() Function The Imagick::setResourceLimit() function is an inbuilt function in PHP which is used to set the limit for a particular resource. Syntax: int Imagick::setResourceLimit( int $type, int $limit ) Parameters: This function accepts two parameters as mentioned above and described below: $type: It specifies 1 min read PHP | parse_url() Function The parse_url() function is an inbuilt function in PHP which is used to return the components of a URL by parsing it. It parses an URL and return an associative array which contains its various components. Syntax: parse_url( $url, $component = -1 ) Parameters: This function accepts two parameters as 2 min read PHP | readdir() Function The readdir() function in PHP is an inbuilt function which is used to return the name of the next entry in a directory. The method returns the filenames in the order as they are stored in the filenamesystem. The directory handle is sent as a parameter to the readdir() function and it returns the ent 2 min read PHP | Imagick getResource() Function The Imagick::getResource() function is an inbuilt function in PHP which is used to get the specified resource's memory usage. Syntax:  int Imagick::getResource( int $type ) Parameters: This function accepts a single parameter $type which holds an integer value corresponding to one of RESOURCETYPE 1 min read PHP | get_defined_vars() Function The get_defined_vars() function is an inbuilt function in PHP which is used to returns an array of all defined variables. This function returns a multidimensional array which contains all the list of variables, environment etc. Syntax: array get_defined_vars( void ) Parameters: This function does no 1 min read PHP | random_int() Function The random_int () is an inbuilt function in PHP. The main function is to generate cryptographically secure pseudo-random integers value. When unbiased results occur in critical condition, then generated cryptographic random integers are used.The different sources of randomness used in this function 2 min read PHP | readfile( ) Function The readfile() function in PHP reads a file and writes its contents directly to the output buffer (usually the browser). Itâs an easy way to show a file without reading it line by line yourself.If thereâs a problem reading the file, like if it doesnât exist, PHP will usually show an error message. T 3 min read Like