Welcome Guest, Not a member yet? Register   Sign In
__construct
#1

[eluser]jbads[/eluser]
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.
#2

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

// Call a function of the object
$my_object->some_function();

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.
#3

[eluser]jbads[/eluser]
Beauty, thank you mate.




Theme © iAndrew 2016 - Forum software by © MyBB