Passing a lot of info from one class to another?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Passing a lot of info from one class to another?

Post 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..
User avatar
MindOverBody
Forum Commoner
Posts: 96
Joined: Fri Aug 06, 2010 9:01 pm
Location: Osijek, Croatia

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

Post 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.
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

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

Post by psychotomus »

pretty simple. Thanks!!
Post Reply