$foo = new Foo ();$foo->bar = new Bar ($foo);
class Foo{ function constructor(){ this->bar = new Bar ($this); }}
Ahoj, 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]$foo = new Foo ();$foo->bar = new Bar ($foo);Kód: [Vybrat]class 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);