exception handling - PHP finally clause -


what best practice simulate clause? realize considered related (though don't think it's duplicate) of this question.

however, in case want handle exceptions, want use (or whatever php equivalent or practice) defined python:

a clause executed before leaving try statement, whether exception has occurred or not.

just loosely writing code after try-catch block seems ugly practice me.

in rfc adding php, suggest workaround:

<?php $db = mysqli_connect(); try {    call_some_function($db); } catch (exception $e) {    mysqli_close($db);    throw $e; } mysql_close($db); 

so unless upgrade php 5.5 (which contain finally construct), best option.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -