PHP Classes

File: autoload.php

Recommend this page to a friend!
  Classes of António Lira Fernandes   Web Service PHP JSON   autoload.php   Download  
File: autoload.php
Role: Auxiliary script
Content type: text/plain
Description: Configuration script
Class: Web Service PHP JSON
API example that stores information in JSON files
Author: By
Last change:
Date: 29 days ago
Size: 380 bytes
 

Contents

Class file image Download
<?php

spl_autoload_register
(function ($class) {

   
$prefix = '';

   
$base_dir = __DIR__.'/';

   
$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;
    }
});

?>