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
67interface_polymorphism.php
67interface_polymorphism.php
<?php /** *Primjer pokazuje polimorfizam */ interface X { public function metoda(); } class A implements X { public function metoda(){ echo "Metoda A "; } } class B implements X { public function metoda(){ echo "Metoda B "; } } $obj_a=new A; $obj_b=new B; $niz=array($obj_a , $obj_b); foreach($niz as $obj){ echo $obj->metoda(); } ?>
Reload page
Preview
W3C validation
Edit Code