The is_resource() function is used to detect whether the variable is a resource type.
PHP version requirements: PHP 4, PHP 5, PHP 7
bool is_resource (mixed $var)
Parameter description:
$var: The variable to be tested.
If the specified variable is of resource type, is_resource() returns TRUE, otherwise it returns FALSE.
In the following example, you need to create the demo.txt file in the current directory.
The output is:
File opened successfully...