Why Kohana is used before () and after ()

I just started playing with Kohana based on CodeIgniter and direct php. I was wondering why Kohana uses the before() and after() functions, rather than regular constructors and destructors?

+4
source share
1 answer

There is a subtle difference between 2:

constructor and destructor is called when an instance is created and destroyed.

The before and after methods are called before and after the controller action.

In addition, you cannot guarantee that constructor and destructor are called before and after the action, but you can guarantee that for the before and after methods.

+8
source

Source: https://habr.com/ru/post/1388917/


All Articles