How can I get around the lack of a finally block in PHP?

前端 未结 7 2189
不思量自难忘°
不思量自难忘° 2020-12-08 18:26

PHP prior to version 5.5 has no finally block - i.e., whereas in most sensible languages, you can do:

try {
   //do something
} catch(Exception ex) {
   //ha         


        
7条回答
  •  被撕碎了的回忆
    2020-12-08 18:47

    I just finished writing a more elegant Try Catch Finally class which may be of use to you. There are some drawbacks but they can be worked around.

    https://gist.github.com/Zeronights/5518445

提交回复
热议问题