How can you check if a file resource opened with fopen has been closed in PHP?

When working with file resources opened with `fopen` in PHP, it is important to check if the file has been closed to prevent potential issues like memory leaks or file access conflicts. One way to do this is by using the `is_resource` function in PHP to check if the file resource is still open.

$file = fopen("example.txt", "r");

// Perform operations with the file resource

if (is_resource($file)) {
    fclose($file);
    echo "File closed successfully.";
} else {
    echo "File is already closed.";
}