What is the potential issue with passing resources by reference in PHP functions?

Passing resources by reference in PHP functions can lead to unexpected behavior and potential memory leaks, as resources are not automatically garbage collected. To solve this issue, it is recommended to pass resources by value instead of by reference. This way, the resource will be properly cleaned up when it goes out of scope.

// Passing resource by value instead of by reference
function processResource($resource) {
    // Do something with the resource
}

// Example usage
$handle = fopen('example.txt', 'r');
processResource($handle);
fclose($handle);