Ok, so, with the code below:
class Core {
public $child;
public function start() {
$child = Loader::instance('Child');
print_r($this);
}
}
class Loader extends Core {
public static $instances;
public static function instance($class) {
if(!isset(self::$instances[$class])) {
self::$instances[$class] = new $class();
}
return self::$instances[$class];
}
}
class Child extends Core {
public function __construct() {
parent::__construct();
$this->child = 'test';
}
}
Loader::instance('Core')->start();
I should be able after a print_r($this) to see:
Core Object
(
[child] => test
)
instead of
Core Object
(
[child] =>
)
what is happening now?
Thanks again..