class test {
function callback(){
echo "Test okay ";
}
}
class classload{
var $class_instance;
function __construct(){
spl_autoload_register (array( $this , 'library' ));
}
public function __call ($fn , array $args ){
if(isset( $this ->{ $fn })){
array_unshift( $args , $this );
call_user_func_array ( $this ->{ $fn }, $args );
}
}
function library($class){
$this->{$class} = new $class($this);
//$this->class_instance = ${$class};
return $this;
}
}
class classtwo {
protected $load;
function __construct(){
$this->load = new classload();
}
}
class Classone extends classtwo {
function view(){
//load and initialise class
$this->load->library('test');
// print_r($this->load->library('test'));
echo $this->test->callback();
}
}
$init = new classone();
echo $init->view();
return error undefined property classone::$test
and also call object ->callback() on null
I have tried to change object into variable but am still getting this error.