I want to do something like the following:
class SomeOtherClass {}
class Test
{
public $member = new SomeOtherClass();
}
The only problem is that I do not want to use a constructor, because the 'Test' class should extend another class and should not override the constructor. Is this actually possible in PHP?
You can extend parent constructor in Test
like this:
class Test extends SomeClass
{
public $member;
function __construct() {
$this->member = new SomeOtherClass();
parent::__construct();
}
}