PHP Classes

File: autoloader.php

Recommend this page to a friend!
  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: 11 years ago
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();
?>