Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

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
HomeMenu