Forum Moderators: coopster
class super{
private $a = "Test";
public function getA(){
return $this->a;
}
}
class sub{
public $get = new super();
}
$obj = new sub();
echo ($obj->get->getA());
The error that is being displayed is
Parse error: syntax error, unexpected T_NEW in #*$! on line 11
So you need to do something like this:
class super {
private $a = "Test";
public function getA(){
return $this->a;
}
}
class sub {
public $get;
public function __construct()
{
$this->get = new super();
}
}
$obj = new sub();
echo ($obj->get->getA());