Re: Possibility to add finally to try/catch?
On Tue, February 28, 2012 8:22 am, Kiall Mac Innes wrote:
> +1000
>
> This is a feature that I've always wanted in PHP, My main reason being
> to
> reduce code duplication. eg
>
> try {
> $fh = fopen($filename);
>
> // Do some work on the file + encounter an error.
> throw new Exception();
> } catch (Exception $e) {
> // Log an error or something
+ if ($fh) fclose($fh); //many PHP file errors NULL out the $fh
+ }
- > } finally {
- > fclose($fh);
- > }
Another non-compelling example...
Still not saying "finally" is a bad idea.
Just want a compelling use case before I would vote...
--
brain cancer update:
http://richardlynch.blogspot.com/search/label/brain%20tumor
Donate:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE
Thread (19 messages)