get_resource_type()
get_resource_type() — Returns the resource type.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.0.2, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
This function gets the type of the given resource.
Signature
get_resource_type(resource $resource): string
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $resource | resource | The evaluated resource handle. |
Return value
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.
Example
A runnable snippet:
$fp = fopen("foo", "w"); echo get_resource_type($fp) . "\n";
Output:
stream
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page get_resource_type() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.