❮ PHP Variable Handling Reference
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 »
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.
is_resource(
variable);
Parameter | Description |
---|---|
variable | Required. Specifies the variable to check |
Return Value: | TRUE if variable is a resource, FALSE otherwise |
---|---|
Return Type: | Boolean |
PHP Version: | 4.0+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!