An abstract class is a mix between an interface and a class. It can be define functionality as well as interface.
abstract class MyAbstract { //Methods } //And is attached to a class using the extends keyword. class Myclass extends MyAbstract { //class methods }
<?php abstract class a { abstract public function dis1(); abstract public function dis2(); } class b extends a { public function dis1() { echo "rookienerd"; } public function dis2() { echo "SSSIT"; } } $obj = new b(); $obj->dis1(); $obj->dis2(); ?>
Output:
<?php abstract class Animal { public $name; public $age; public function Describe() { return $this->name . ", " . $this->age . " years old"; } abstract public function Greet(); } class Dog extends Animal { public function Greet() { return "Woof!"; } public function Describe() { return parent::Describe() . ", and I'm a dog!"; } } $animal = new Dog(); $animal->name = "Bob"; $animal->age = 7; echo $animal->Describe(); echo $animal->Greet(); ?>
Output: