PHP Classes

File: autoload.php

Recommend this page to a friend!
  Classes of Unay Santisteban   Database PDO Abstract Layer   autoload.php   Download  
File: autoload.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Database PDO Abstract Layer
Run queries with PDO and get results in XML, JSON
Author: By
Last change: Update of autoload.php
Date: 29 days ago
Size: 431 bytes
 

Contents

Class file image Download
<?php

/**
 * Local autoload file
 */
spl_autoload_register(function ($class) {
   
$prefix = 'OtherCode\Database\\';
   
$base_dir = __DIR__ . '/src/';
   
$len = strlen($prefix);
    if (
strncmp($prefix, $class, $len) !== 0) {
        return;
    }
   
$relative_class = substr($class, $len);
   
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
    if (
file_exists($file)) {
        require
$file;
    }
});