Current Location: Home> Function Categories> get_resource_type

get_resource_type

Return resource type
Name:get_resource_type
Category:Variable processing
Programming Language:php
One-line Description:Returns the type of the resource.

Definition and usage

get_resource_type() function returns the type of the resource.

Example

Return resource type:

 <?php
$file = fopen ( "test.txt" , "r" ) ;
echo get_resource_type ( $file ) ;
?>

Try it yourself

Example explanation:

$file is a file resource opened through fopen() function. get_resource_type($file) will return the type of the resource, usually "stream" . If the file does not exist or cannot be opened, fopen() returns FALSE , but no error checking is performed in this example. In practical applications, the return value of fopen() should be checked to ensure that the file has been opened successfully. If $file is not a valid resource, get_resource_type($file) will return NULL and may generate an error. In versions prior to PHP 5.3, it will return FALSE instead of NULL .

grammar

 get_resource_type ( resource ) ;
parameter describe
resource Required. Specify the resource to be inspected.
Similar Functions
Popular Articles