Yii Framework – Encapsulation and Inheritance

Yii Framework – Encapsulation and Inheritance

Video 2 : Understanding Encapsulation and Inheritance Concepts – Yii Framework for Beginners

Encapsulation

Wrapping the related member variable and member functions together

[php]
class A {

$a = 10; // member variable

$b = 20; // member variable

function add($a, $b){ //logic }

function substract($a, $b){ //logic }

}

[/php]

Best Example for encapsulation is  “Class”

 

Inheritance

“Aquaring the Parent Properties to Child Class”

Example : Mother   Father (Rich) 100 MD Kid (D+ KP) 10MD +100 =110 MD

[php]

class A {

$a = 10; // member variable

$b = 20; // member variable

function add($a, $b){ //logic }

function substract($a, $b){ //logic } …

}

class B extends A {

add(10,2);

}

[/php]

Add a Comment

Your email address will not be published. Required fields are marked *