$foo = new Foo ();$foo->bar = new Bar ($foo);
class Foo{ function constructor(){ this->bar = new Bar ($this); }}
Citace od: Host kdy 02. 04. 2017, 18:26:55Ahoj, který zápis je správně? Potřebuji přidat objekt $foo tříde Bar a nevím jak to správně udělat. Díky.Kód [Vybrat] Rozbalit$foo = new Foo ();$foo->bar = new Bar ($foo);Kód [Vybrat] Rozbalitclass Foo{ function constructor(){ this->bar = new Bar ($this); }}
class A { function __construct($foo) { $this->foo = $foo; } function a() { $this->foo->a(); }}
$foo = new Foo();$bar = new Bar($foo);