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
13constants.php
13constants.php
<?php class MojaKlasa { const PII=3.14; public function ispis() { return self::PII; } } class DodanaKlasa extends MojaKlasa { public $sv2=parent::PII; public function ispis2() { return MojaKlasa::PII; //moze ici i parent::PII; } } //defininranje objekta $obj=new DodanaKlasa; echo MojaKlasa::PII; //pozivanje konstante izvan klase echo $obj->sv2; echo $obj->ispis(); echo $obj->ispis2(); ?>
Reload page
Preview
W3C validation
Edit Code