Put cleanup in finally so it runs after success, an exception, or an early return: ~~~php $handle = fopen($path, 'rb'); try { return $this->read($handle); } finally { fclose($handle); } ~~~ Use finally for file handles, transactions, and other resources; log or rethrow failures rather than hiding them.
Installs into .claude/skills of the current project.
Are you the author of Php Error Handling?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-php-error-handling-2e89f461)
Put cleanup in finally so it runs after success, an exception, or an early return:
~~~php
$handle = fopen($path, 'rb');
try {
return $this->read($handle);
} finally {
fclose($handle);
}
~~~
Use finally for file handles, transactions, and other resources; log or rethrow failures rather than hiding them.