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
namespaces
full_example
index1.php
index1.php
<?php namespace libra1; //code ovog fajla nalazi se u libra1 namespace-u include("./inc/spl_autoload.inc.php"); /** ./libra1/jedanprva.class.php**/ $obj=new JedanPrva; echo $obj->sv; $obj->metoda(); /** ./libra1/jedandruga.class.php**/ $obj=new JedanDruga; echo $obj->sv; $obj->metoda(); /** ./libra1/libra1_1/subjedan.class.php sa use**/ use \libra1\libra1_1\SubJedan; //isto kao use \libra1\libra1_1\SubJedan as SubJedan; $obj=new SubJedan; echo $obj->sv; $obj->metoda(); /** ./libra1/libra1_1/subjedan.class.php bez use**/ $obj=new \libra1\libra1_1\SubJedan; //ili krace libra1_1\SubJedan; posto smo vec u libra1 namespacu echo $obj->sv; $obj->metoda(); /** ./libra2/dva.class.php**/ use \libra2\Dva; //isto kao use \libra2\Dva as Dva; $obj=new Dva; echo $obj->sv; $obj->metoda(); ?>
Reload page
Preview
W3C validation
Edit Code