Take this example:
class Container {
public $text;
public $variable2;
}
class Text {
public $other_variable;
}
How can I assign a Text instance to Container::$variable, without using the __construct method?
In the end I want this effect:
$class = new Container();
$class->text->other_variable;
If I try the following, PHP gives me an error:
class Container {
public $variable = new Text();
public $variable2;
}