PHP Classes

File: reliq/autoload.php

Recommend this page to a friend!
  Packages of Arthur Borisow   reliq   reliq/autoload.php   Download  
File: reliq/autoload.php
Role: Configuration script
Content type: text/plain
Description: Configuration script
Class: reliq
Compose relational queries programmatically
Author: By
Last change:
Date: 14 years ago
Size: 816 bytes
 

 

Contents

Class file image Download
<?php

    spl_autoload_register(function($class_name) {
            $class_name = explode('\\', $class_name);
            $package = array_shift($class_name);
            
            if ($package != 'Reliq') {
                return false;
            }

            $name = array_pop($class_name);

            $name = preg_replace('/(?<!^)([A-Z])([a-z\d]*)/', '_$1$2',
                                 $name);

            $class_name[] = $name . '.php';
            $class_path = dirname(__FILE__) . DIRECTORY_SEPARATOR
                          . strtolower(implode(DIRECTORY_SEPARATOR,
                                               $class_name));
            if(file_exists($class_path)) {
                require_once $class_path;
            } else {
                return false;
            }
        });