PHP is_resource() Function
❮ PHP Variable Handling Reference
Example
Check whether a variable is a resource or not:
<?php
$file = fopen("test.txt","r");
if (is_resource($file)) {
echo
"File is open";
} else {
echo "Error open file";
}
?>
Run Example »
Definition and Usage
The is_resource() function checks whether a variable is a resource or not.
Note: The is_resource() function will return FALSE if the resource has been closed.
This function returns true (1) if the variable is a resource, otherwise it returns false/nothing.
Syntax
is_resource(variable);
Parameter Values
Parameter | Description |
---|---|
variable | Required. Specifies the variable to check |
Technical Details
Return Value: | TRUE if variable is a resource, FALSE otherwise |
---|---|
Return Type: | Boolean |
PHP Version: | 4.0+ |
❮ PHP Variable Handling Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.