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
28constructor_objectArg.php
28constructor_objectArg.php
<?php class Oglasavaci { public $ime; public $prezime; public function __construct($p1,$p2) { $this->ime=$p1; $this->prezime=$p2; } } class Oglasi { public $id; public $oglas; public $oglasavac; public function __construct($p1,$p2,Oglasavaci $p3){ $this->id=$p1; $this->oglas=$p2; $this->oglasavac=$p3; } } $jozo=new Oglasavaci('Josip','Josipovic'); $jozinOglas=new Oglasi(125,'Prodajem kucu na moru.',$jozo); echo $jozinOglas->oglasavac->ime; //daje: Josip echo $jozinOglas->oglas; //daje: Prodajem kucu na moru. var_dump($jozinOglas); ?>
Reload page
Preview
W3C validation
Edit Code