Login   Register  
PHP Classes
elePHPant
Icontem

File: autoloader.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of jumping-blueberry  >  Jb Data Binding  >  autoloader.php  >  Download  
File: autoloader.php
Role: Application script
Content type: text/plain
Description: autoloader for all of my classes
Class: Jb Data Binding
Compose and process forms to edit MySQL records
Author: By
Last change:
Date: 2013-01-17 15:37
Size: 589 bytes
 

Contents

Class file image Download
<?php class Autoloader {
    public function 
__construct() {
        
spl_autoload_register(array($this'loader'));
    }
    private function 
loader($className) {
        
$fileName=str_replace("_","/",$className);
        
//__DIR__ added PHP 5.3
            
if(defined('__DIR__')){
                
$currentDir=__DIR__;
            }else{
                
$currentDir=dirname(__FILE__);
            }
            
$fileName=$currentDir.'/'.$fileName.'.php' ;
        
//echo "Trying to load ".$className.": ".$fileName;
        
if(is_file($fileName)){        
        
//echo "file exists";
        
require_once $fileName;
        }else{
        
//echo "file does not exist";    
        
}
    }
}


$autoloader = new Autoloader();
?>