Skip to main content

Posts

Showing posts from June, 2021

ABSTRACTION

  ABSTRACTION It is a process of hiding internal structure or implementation details. Abstract Class: In abstract class, it contains at least one or more abstract method. When Classes defined as abstract, then it may not be instantiated. Abstract Method: In abstract method, only declaration of method have in the abstract class. Another Class inherits the abstract class then the implementation or definition is defined into the derived class. Abstract method can not be declared as  Private. Example: abstract Class A {     abstract public function calSquare($no); } Class B extends A {     public function calSquare($no) {         return $no * $no;     } } $objB = new B(); echo $objB->calSquare(5);

ENCAPSULATION

ENCAPSULATION It is process of encapsulating or wrapping up member properties and methods in a single module. If class used the Abstraction and D ata Hiding then such type of class is known as encapsulation class. class Animal{ private $name; public function setName($name) { $this->name = $name; } public function getName($name) { return $this->name; } } $animalObj = new  Animal (); $ animalObj  ->setName('Lion'); $ animalObj  ->getName(); // Output Lion