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
60abstract_constructor.php
60abstract_constructor.php
<?php /** Primjer pokazuje da iako objekt abstraktne klase se ne moze kreirati * da se constructor moze definirati. Taj se konstruktor kasnije nasljedjuje * u child klasama **/ abstract class Zaposlenici { public $ime; public $prezime; public function __construct($p1,$p2) { $this->ime=$p1; $this->prezime=$p2; } } class Prevoditelji extends Zaposlenici { public $jezik; public function __construct($p1,$p2,$p3=null) { parent::__construct($p1,$p2); $this->jezik=$p3; } } class Programeri extends Zaposlenici { public $programski_jezik; public function __construct($p1,$p2,$p3) { parent::__construct($p1,$p2); $this->programski_jezik=$p3; } } $prev1=new Prevoditelji('Ana','Markic','Njemacki'); $prev2=new Prevoditelji('Eva','Evic'); $prog1=new Programeri('Ivo','Ivic','Java'); //$prog2=new Programeri('Ante','Antic'); greska jer nema $p3=null var_dump($prev1); var_dump($prev2); var_dump($prog1); ?>
Reload page
Preview
W3C validation
Edit Code