What are the potential pitfalls of using is_resource() for checking resource status in PHP?

Using is_resource() to check the status of a resource in PHP can be unreliable because it only checks if a variable is a resource type, not if the resource is valid or still open. To accurately check the status of a resource, it's better to use functions specific to the type of resource, such as fclose() for file resources.

// Check if a file resource is valid and open
if (is_resource($fileHandle) && !feof($fileHandle)) {
    // File resource is valid and open
    // Perform operations on the file
} else {
    // File resource is not valid or closed
    // Handle the error accordingly
}