Page 1 of 1

Passing a lot of info from one class to another?

Posted: Sat Mar 19, 2011 12:50 pm
by psychotomus
How can I pass my user class info to another class? I hear of this thing called inherit but never used it. I got a lot of user vars..

Re: Passing a lot of info from one class to another?

Posted: Sat Mar 19, 2011 8:31 pm
by MindOverBody

Code: Select all

class Person {
     public $name;
     public $surname;
}

class Employee extends Person {
     public $skill;
     public $salary;
}
In this context, If you make instance of Employee class, it will have both its properties ( skill, salary ) and name, surname from parent class.
But, if you make instance of Person, your object will hold only name and surname properties. It's simple as that.

Re: Passing a lot of info from one class to another?

Posted: Sun Mar 20, 2011 9:33 am
by psychotomus
pretty simple. Thanks!!