Abstract class with Constructors and Destructors
I am going to show you an example which uses the abstract class and can be adjusted with the code of pHP which would be as follows :
Code:
<?php
abstract class animal
{
abstract function gt_owned();
private $age;
protected function __construct($age) {
$this->age = $age;
}
public function gt_age()
{
return $this->$age;
}
}
?>
<body><h1>Abstract class code</h1>
<?php
$charlie = new animal(6);
$catage = $charlie -> getage();
print "Charlie is $catage years old<br>";
?>
<hr>
</body>
Bookmarks