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
39visibility_methodOverride.php
39visibility_methodOverride.php
<?php class A { //definiranje neke public,protected i private metode public function pub(){echo 'PublicMetoda ';} protected function prot(){echo 'ProtectedMetoda ';} private function priv(){echo 'PublicMetoda ';} } class B extends A { //override metoda public function pub(){echo 'PublicOverriden ';} protected function prot(){echo 'ProtectedOverriden ';} private function priv(){echo 'PrivateOverriden ';} public function ispis_b() { $this->pub(); $this->prot(); $this->priv(); } } //SUBCLASS $obj_b=new B; $obj_b->ispis_b(); //ispisuje: PublicOverriden ProtectedOverriden PrivateOverriden var_dump($obj_b); ?>
Reload page
Preview
W3C validation
Edit Code