get_resource_type
Return resource type
get_resource_type()
function returns the type of the resource.
Return resource type:
<?php $file = fopen ( "test.txt" , "r" ) ; echo get_resource_type ( $file ) ; ?>
Try it yourself
$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
.
get_resource_type ( resource ) ;
parameter | describe |
---|---|
resource | Required. Specify the resource to be inspected. |