Thursday, September 25, 2025
HomeLanguagesPHP get_resource_type() Function

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.

Return Values: The function will return the string representing its type if the given resource is a resource. If the function does not determine the type of resource It will return Unknown.

Example 1: In the following example, we will print the type of resource by using the get_resource_type() function.

PHP




<?php
    $file_text = fopen("text.txt","rb") ;
    echo get_resource_type($file_text) ;
?>


Output:

stream

Example 2: In the below example, will print the Unknown when you used the get_resource_type() function without passing any resource to the function.

PHP




<?php
    $file_text = fopen("text.txt","rb") ;
    echo get_resource_type($file_text)."\n" ;
    fclose($file_text);
    echo get_resource_type($file_text) ;
?>


Output:

stream
Unknown

Reference: https://www.php.net/manual/en/function.get-resource-type.php

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32319 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6681 POSTS0 COMMENTS
Nicole Veronica
11854 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11910 POSTS0 COMMENTS
Shaida Kate Naidoo
6794 POSTS0 COMMENTS
Ted Musemwa
7070 POSTS0 COMMENTS
Thapelo Manthata
6753 POSTS0 COMMENTS
Umr Jansen
6761 POSTS0 COMMENTS