Current Location: Home> Function Categories> is_resource

is_resource

Detect whether the variable is a resource type
Name:is_resource
Category:Variable processing
Programming Language:php
One-line Description:Check whether the variable is a resource type.

Definition and usage

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.

Example

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

grammar

 is_resource ( variable ) ;
parameter describe
variable Required. Specifies the variable to check.
Similar Functions
Popular Articles