Toggle navigation
Genres
Frontend (2)
JavaScript (6)
Database (2)
Linux Server (3)
Web Apps (4)
Misc (4)
Search
List
New Tutorials
Last Modified Tutorials
</>
Code examples
code
smiko
backend
php
oop
classes_objects
z960property_as_object_container.php
z960property_as_object_container.php
<?php /**Primjer pokazuje kako svojstvo moze biti niz objekata Skladisti svaki instancirani objekt u sebe (container) ******************** STATIC ***************************/ class MojaKlasa { public static $container=array(); //skladisti svaki instancirani objekt u sebe public $sv; public function __construct($sv){ $this->sv=$sv; array_push(self::$container , $this); } } $obj=new MojaKlasa('svojstvo1'); $obj=new MojaKlasa('svojstvo2'); $obj=new MojaKlasa('svojstvo3'); var_dump(MojaKlasa::$container); echo '<hr/>'; //pozivanje svojstva 2. objekta tj. $obj2 echo MojaKlasa::$container[1]->sv; ?>
Reload page
Preview
W3C validation
Edit Code