So I have been thinking about this for a while and wondering if my init function is even working at all. This stems from the idea of object initialization in Zend Framework.
Lets Assume I have a base class like such:
class Base{
public function __construct(){
$this->init();
}
public function init(){}
}
Now lets assume I have a class from this that needs to accept a options param in the constructor. Why you wouldn't use the init function in the parent class I have no idea, but this example is based off of real code that I can't share.
class ExtendsBase extends Base{
private $_options;
public function __construct($options){
parent::__construct();
$this->_options = $options;
}
// Why even instantiate this if never using it?
public function init(){
parent::init();
}
}
So from there we need to extend from this and actually populate init with some things.
class EchoHello extends ExtendsBase{
public function init(){
parent::init();
echo "hello"; exit;
}
}
And then we should be able to do this:
$someVar = new EchoHello(array());
// Instantiate should echo hello and exit.
The issue is that echo "hello"; exit;
is never executed. Is there something wrong with the inheritance chain?