PHP Training in Chandigarh is the best place to learn about PHP coding . OOPs Concepts in PHP is Very important and mostly used . Learn PHP Inheritance by Watching this Presentation
2. Object Inheritance
Inheritance is a well-established programming
principle, and PHP makes use of this principle
in its object model. This principle will affect the
way many classes and objects relate to one
another.
For example, when you extend a class, the
subclass inherits all of the public and protected
methods from the parent class. Unless a class
overrides those methods, they will retain their
original functionality.
3.
4. How can a
child class
have its own
methods
and
properties?
ust as a child class can use the properties and
methods of its parent class, it can have properties
and methods of its own as well. However, while a
child class can use the code it inherited from the
parent, the parent class is not allowed to use the
child class’s code.
In the example given below, we will add to the child
class some code of its own by adding the $style
property as well as the driveItWithStyle() method:
5. The parent class has its properties and methods
class Car {
//A private property or method can be used only
by the parent.
private $model;
// Public methods and properties can be used by
both the parent and the child classes.
public function setModel($model)
{ $this -> model = $model;
}
public function getModel()
{ return $this -> model;
}
}
6. CBitss Technologies
SCO 23-24- 25, Level 3,
Near Passport office,
Sector 34 A, Chandigarh.
Contact Us:- 9914641983.
Website:- http://cbitss.in/php-training-in-chandigarh/