get_resource_type

Returns the resource type

Syntax

get_resource_type ( resource $handle ) : string

Parameters

handle

The evaluated resource handle.

Return

If the given handle is a resource, this function will return a string representing its type. If the type is not identified by this function, the return value will be the string Unknown.

This function will return NULL and generate an error if handle is not a resource.

Examples

1

<?

$handle = tmpfile();

$return = get_resource_type($handle);

echo $return;

?>
stream

2

<?

$filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/txt/file.txt";
$mode = "r";

$handle = fopen($filename, $mode);

    $return = get_resource_type($handle);
    
    echo $return;

fclose($handle);

?>
stream

3

<?

$filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/txt/file.txt";
$mode = "r";

$handle = fopen($filename, $mode);
fclose($handle);

$return = get_resource_type($handle);

echo $return;

?>
Unknown

get_resource_id

boolval

debug_zval_dump

doubleval

empty

floatval

get_debug_type

get_defined_vars

get_resource_id

gettype

intval

is_array

is_bool

is_callable

is_countable

is_double

is_float

is_int

is_integer

is_iterable

is_long

is_null

is_numeric

is_object

is_real

is_resource

is_scalar

is_string

isset

print_r

serialize

settype

strval

unserialize

unset

var_dump

var_export

PHP

Home Menu