is_resource

bool is_resource(mixed value) 

Tests whether a value is a resource pointer.

Returns:

TRUE if the value is a resource pointer; FALSE otherwise

Description:

is_resource() checks whether value is a resource pointer that has been returned by a call to fopen(), popen(), opendir(), etc., or one of the database functions such as mysql_connect(), msql_pconnect(), etc. If so, the function returns TRUE. If not, FALSE is returned.

Availability:

UNIX, Windows

Version:

3+, 4+

See also:

gettype() 

Example:

Test whether a value is a resource pointer
$dir_handle = opendir ('..'); 

if (is_resource ($dir_handle)) 
    print '$dir_handle is a resource pointer.'; 
else 
    print '$dir_handle is not a resource pointer.'; 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.