Possible Duplicate:
Understanding Classes in PHP
I pretty often see “extends” in classes, like
class a
{
// its content here
}
class b extends a
{
//other content here
}
What’s the job of extends?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is a OOP principle called Inheritance.
When a class
Binherits (extends) from classA, an instance of classBinherits all the functionality from classAand has access toprotected(and of coursepublic) methods and attributes viaparent::.Read more about inheritance in PHP.
Inheritance is often used when classes share certain properties.
For example, I can have a class Person that holds information such as
nameand subclassesCustomer,Partner, that inherit the propertynamebut add some custom functionality.