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
08spl_autoload_use.php
08spl_autoload_use.php
<?php /*** class Loader ***/ function lib1_loader($class_name) { $filename=strtolower($class_name).'.php'; $filename=str_replace("\\","_",$filename); $put='./lib1/'.$filename; if(is_readable($put)) {include $put; echo "<br/><b>$put</b><br/>";} else echo "<br/>Greska: <b>$put</b><br/>"; } spl_autoload_register('lib1_loader'); //class aliases use lib1\Prva as P; use lib1\Druga as D; echo "<hr/>"; /**lib1_prva.php**/ $obj=new P; echo $obj->sv; $obj->metoda(); echo \lib1\K; \lib1\fja(); //echo $var; javlja gresku /**lib1_druga.php**/ $obj=new D; echo $obj->sv; $obj->metoda(); ?>
Reload page
Preview
W3C validation
Edit Code