Abstract Classes and Constructors
Posted: Wed Jul 19, 2006 11:34 am
If I have an abstract class, I assume since it can't be instantiated there is no constructor for the class. I want to make sure each class that extends from this abstract class defines a constructor. Does that mean I need to define an abstract method called __construct() in my abstract class to force this?
Code: Select all
abstract class Person{
protected $name;
function getName(){
return $this->name;
}
abstract function __construct(); //enforce constructor here???
}
class Employee extends Person{
function __construct(){
$this->name = "john";
}
}