I've just started having a play with Kohana, coming from CodeIgniter and straight php. I was wondering why Kohana uses the before()
and after()
functions rather than normal constructors and destructors?
There's a subtle difference between the 2:
The constructor
and destructor
are called when an instance is created and destroyed.
The before
and after
methods are called before and after an action of a controller is executed.
Besides that, you can't guarantee the constructor
and destructor
are called before and after the action is executed, but you can guarantee that for the before
and after
methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With