Easy Tutorial
❮ Pdo Quote Php Is_Iterable Function ❯

PHP is_resource() Function

PHP Available Functions

The is_resource() function is used to check if a variable is of type resource.

PHP Version Requirements: PHP 4, PHP 5, PHP 7

Syntax

bool is_resource ( mixed $var )

Parameter Description:

Return Value

If the specified variable is of type resource, is_resource() returns TRUE; otherwise, it returns FALSE.

Example

You need to create a file named demo.txt in the current directory for the following example.

Example

<?php
$fh = fopen('demo.txt','r');
if (is_resource($fh)) 
{
    echo "File opened successfully...";
}
else 
{
    echo "Error opening file";
}
?>

Output:

File opened successfully...

PHP Available Functions

❮ Pdo Quote Php Is_Iterable Function ❯