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
z956object_inside_class.php
z956object_inside_class.php
<?php /**Primjer pokazuje kako se moze instancirati objekt unutar klase**/ class MojaKlasa { public $sv1,$sv2; //moraju biti public public function __construct($p1,$p2){ $this->sv1=$p1; $this->sv2=$p2; } } class DrugaKlasa { public function ispis(){ $obj=new MojaKlasa('svojstvo1','svojstvo2'); //instanca unutar klase echo $obj->sv1; echo $obj->sv2; } } $obj2=new DrugaKlasa; $obj2->ispis(); ?>
Reload page
Preview
W3C validation
Edit Code