Abstraction in PHP

Data Abstraction is the most important features of any OOPS programming language. It shows only useful information, remaining are hidden form the end user. Abstraction is the any representation of data in which the implementation details are hidden (abstracted).

Example 1

snippet
<?php
abstract class Animal
{
public $name;
public $age;
public function Describe()
{
return $this->name . ", " . $this->age . " years old";    
    	}
abstract public function Greet();
}
class cat extends Animal
{
public function Greet()
{
return "Lion!";    
}
public function Describe()
{
return parent::Describe() . ", and I'm a cat!";    
}
}
$animal = new cat();
$animal->name = "Seru";
$animal->age = 5;
echo $animal->Describe();
echo $animal->Greet();

?>

Output:

Abstraction in PHP
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +