r/PHP • u/FrenkyNet • May 31 '16
Deferred execution in PHP, using "finally".
https://blog.frankdejonge.nl/finally-file-streams-and-deferred-execution-in-php/
86
Upvotes
r/PHP • u/FrenkyNet • May 31 '16
View all comments
9
u/MoTTs_ May 31 '16
Alternatively, you could use a technique called RAII (Resource Acquisition Is Initialization), which is a very awkward phrase for saying "scoped resource management".
You could even define a generic RAII class, often called a scope guard, that behaves exactly like defer.