get_resource_type
Description
The get_resource_type of Variable Handling for PHP returns the resource type.
Syntax
get_resource_type( resource $resource ): string
Parameters
resource
The evaluated resource handle.
Return
If the given resource 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 resource is not a resource.
Examples
1 · resource · type
<? $filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/txt/1.txt"; $mode = "r"; $resource = fopen($filename, $mode); $return = get_resource_type($resource); echo $return; fclose($resource); ?>
stream
2 · resource · Unknown
<? $filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/txt/1.txt"; $mode = "r"; $resource = fopen($filename, $mode); fclose($resource); $return = get_resource_type($resource); echo $return; ?>
Unknown
Links
Related
Variable Handling
- 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