is_resource
Detect whether the variable is a resource type
is_resource()
function is used to check whether the variable is a resource type.
Note: If the resource is closed, is_resource()
function returns FALSE
.
If the variable is a resource, the function returns true
(1), otherwise false
/ no return value.
Check if a variable is a resource:
<?php $file = fopen ( "test.txt" , "r" ) ; if ( is_resource ( $file ) ) { echo "File is open" ; } else { echo "Error open file" ; } ?>
Try it yourself
is_resource ( variable ) ;
parameter | describe |
---|---|
variable | Required. Specifies the variable to check. |