Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
What are differences between before() and __construct()?
  • http://fuelphp.com/docs/general/controllers/base.html What is the point to have before() and after() when you have constructor and destructor? Please can anyone explain the differences? Thanks in advance.
  • The Constructor is used by Fuel, you can extend it but if you do you need to copy its parents behavior in order not to break it. "before()" is just an easier alternative. after() is called directly after your controller method was called but before the output was send. A __destruct() method is called when the controller instance is destroyed, this happens after output was send and limits what is possible because other objects may already have been destroyed.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion