Hey!
I've got a problem with a couple of classes I'm using, which I'm unsure how to solve because I'm relatively new to classes.
Basically what I have is 2 classes.. User and PageAccess (which extends User)
I set up a User object with:
$usr = new User;
And then set up my PageAccess object with
$auth = new PageAccess(1);
The constructor of PageAccess calls User by doing this:
parent::__construct();
However, if I put a print line in my User constructor.. I notice that it is printed out twice when just doing the above code..
I'm assuming this is because I'm setting up an object myself, then getting the constructor of the child class to set another up.. but how can I get around this, because if I remove my own (the first) initialisation I get errors because the elements in the User class cannot be called.
All works fine otherwise, but I don't want it running twice everytime.. because it is used a lot!
So, basically my question is.. how should I link the parent object to the child object, so I only need to create one parent object.. then link it to the child..
Asumming that is how it should work, if not .. please help! I'm confused!