Hi, Dmitri

Great that someone's mentioning it.
I thought about that several times but did not put it in here.

This is a must-have for me. Really useful if you're working with external
resources (streams, database connection etc).
I used a destructor until now for stuff like that but there are some
situations where a destructor won't be called.
http://stackoverflow.com/questions/2385047/when-will-destruct-not-be-called-in-php

Bye
Simon

2012/2/28 Paul Dragoonis <dragoo...@gmail.com>

> Tried to do something the other day and had to write something a bit quirky
> tht would have been super clean with a finally block.
>
> +1000
>
> On Tue, Feb 28, 2012 at 2:22 PM, Kiall Mac Innes <ki...@managedit.ie>
> 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
> > } finally {
> >    fclose($fh);
> > }
> >
> > Thanks,
> > Kiall
> >
> >
> > On Tue, Feb 28, 2012 at 2:05 PM, Dmitri Snytkine <
> > dsnytk...@ultralogistics.com> wrote:
> >
> > >
> > > This is another feature that we know we can live without
> > > but those familiar with languages that have 'finally' like Java or
> Python
> > > know that
> > > it is very neat feature to have in some situations.
> > >
> > > Basically the code inside 'finally' is guaranteed to run even if there
> > is a
> > > 'return' inside try or catch blocks
> > > in which case the value to be returned is remembered tempraraly, the
> code
> > > inside finally block executes and then remembered value is returned.
> > >
> > >
> > > Dmitri Snytkine
> > > Web Developer
> > > Ultra Logistics, Inc.
> > > Phone: (888) 220-4640 x 2097
> > > Fax: (888) 795-6642
> > > E-Mail: dsnytk...@ultralogistics.com
> > > Web: www.ultralogistics.com
> > >
> > > "A Top 100 Logistics I.T. Provider in 2011"
> > >
> > >
> > >
> > >
> > > --
> > > PHP Internals - PHP Runtime Development Mailing List
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
>

Reply via email to