Login   Register  
PHP Classes
elePHPant
Icontem

File: autoLoader.inc.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Oliver Anan  >  PHP One Line Enum  >  autoLoader.inc.php  >  Download  
File: autoLoader.inc.php
Role: Auxiliary script
Content type: text/plain
Description: class autoloader
Class: PHP One Line Enum
Create enumerated types from arrays of values
Author: By
Last change:
Date: 3 years ago
Size: 514 bytes
 

Contents

Class file image Download
<?php
/*
 * Register an Autoloader for Co3 classes.
 * This Autoloader assumes that: 
 * -every Namespace has a seperate directory
 * -every class has a seperate file
 * -every class file is named {$classname}.php

 */
spl_autoload_register(
    function(
$name){
        
$classDirectory __DIR__.'/class';
        
$classPath str_replace('\\','/',"{$name}.php");
        
$fullPath "{$classDirectory}/{$classPath}";
        if(
file_exists($fullPath)){
            require (
$fullPath);
        } else {
            return 
false;
        }
    }    
);
?>