次の例を見てください。
class Container {
public $text;
public $variable2;
}
class Text {
public $other_variable;
}
メソッドを使用せずにText
インスタンスをに割り当てるにはどうすればよいですか?Container::$variable
__construct
最後に、私はこの効果が欲しい:
$class = new Container();
$class->text->other_variable;
以下を試してみると、PHP でエラーが発生します。
class Container {
public $variable = new Text();
public $variable2;
}