<?php
// Global Variables
global $class_folder;
$class_folder = ".".DIRECTORY_SEPARATOR."classes"; // to change if your class folder has a different name
// Autoload classes dynamically
function __autoload($class_name) {
global $class_folder;
$path_to_class = $class_folder . DIRECTORY_SEPARATOR . $class_name . '.class.php';
$file = get_path($path_to_class);
if(is_file($file))
try {
include_once $file;
} catch (Exception $e) {
throw new Exception("Unable to load php class file $file from classes folder");
die;
}
else
include_once get_path('./config.php');
}
function get_path($path) {
return realpath($path);
}
|