Thursday, October 16, 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
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS