The most common scenario for try / finally is to release some resources regardless of whether or not an exception occurred.
For example: try { $r = new Something(); $r->doStuff(); } finally { $r->cleanup(); } So $r->cleanup() will run regardless of whether or not the try block code throws an exception. The "ugly hack" cited catches the exception. You could re-throw it but that may not be the desired behavior. You might want to catch one type of exception and yet re-throw another. That's more logic you have to consider. With a finally clause it's very clear that that code is to be executed regardless of what happens (sans program exit). A finally clause would be a good addition to PHP. Mike On Tue, Aug 5, 2008 at 11:18 AM, Guilherme Blanco <[EMAIL PROTECTED]> wrote: > exactly =) > > On Tue, Aug 5, 2008 at 12:14 PM, Justin Dearing <[EMAIL PROTECTED]> wrote: >> So your saying finally could be implemented as >> >> if($e != null){ >> //finally stuff >> } >> >> >> On Tue, Aug 5, 2008 at 11:09 AM, Guilherme Blanco >> <[EMAIL PROTECTED]> wrote: >>> You can do an ugly hack.... supported: >>> >>> >>> try { >>> // ... >>> } catch (Exception $e) { >>> // ... >>> } >>> >>> // finally... you can use $e here, you know?!!?!? =) -- Michael B Allen PHP Active Directory SPNEGO SSO http://www.ioplex.com/ _______________________________________________ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations Online http://www.nyphpcon.com Show Your Participation in New York PHP http://www.nyphp.org/show_participation.php