English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
is_resource() The function is used to check if a variable is of resource type.
PHP version requirement: PHP 4, PHP 5, PHP 7
bool is_resource ( mixed $var )
Parameter Description:
If the specified variable is of resource type, is_resource() returns TRUE, otherwise it returns FALSE.
The following example requires you to create a demo.txt file in the current directory.
<?php $fh = fopen('demo.txt','r'); if (is_resource($fh)) { echo "File opened successfully..."; } else { echo "File opening error"; } ?>
The output is:
File opened successfully...