Hi,
I can understand your problem with the abstract classes.
Please note that an abstract class is a class that is only partially implemented by the programmer. An abstract class is a class with or without data members that provides some functionality and leaves the remaining functionality for its child class to implement. It cannot be instantiated and it can only be extended. Abstract class is prefixed with keyword "abstract".
Abstract classes are one of the PHP answers to polymorphism and inheritance.
Syntax:
Code:
< ?
abstract class classname
{
//attributes and methods
.
.
abstract function methodname
}
class derived extends classname
{
function methodname
}
?>
It's application in a program.
Code:
< ?
abstract class employee
{
protected $empname;
protected $empage;
function setdata($empname,$empage)
{
$this->empname = $empname;
$this->empage = $empage;
}
abstract function outputData();
}
class EmployeeData extends employee //extending abstract class
{
function __construct($name,$age)
{
$this->setdata($name,$age);
}
function outputData()
{
echo $this->empname;
echo $this->empage;
}
}
$a = new EmployeeData("Rabbie","30");
$a->outputData();
?>
Bookmarks