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?
I’ve just started having a play with Kohana, coming from CodeIgniter and straight php.
Share
There’s a subtle difference between the 2:
The
constructoranddestructorare called when an instance is created and destroyed.The
beforeandaftermethods are called before and after an action of a controller is executed.Besides that, you can’t guarantee the
constructoranddestructorare called before and after the action is executed, but you can guarantee that for thebeforeandaftermethods.