• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Do I have this right?

If I put a function call to check authentication in the construct of my class, then I do not need to include that same check on the individual functions / controllers within that class? That authentication check will run before any controllers are accessed?

Sorry for the dipshit question. Just wanna make sure my bases are covered.

[eluser]Pascal Kriete[/eluser]
Exactly right. Normally object oriented programming looks like this:
// Instantiate - this is where the constructor is run
$my_object = new MyClass();

// Call a function of the object

When a controller is run, CodeIgniter does exactly that ... with a few twists (system/codeigniter/CodeIgniter.php line:198 if you're interested).
So as you can see, the constructor doesn't get a choice - it has to run first.

Beauty, thank you mate.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.