PHP Classes

File: autoload.php

Recommend this page to a friend!
  Classes of António Lira Fernandes   Web Service PHP MySQL   autoload.php   Download  
File: autoload.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Web Service PHP MySQL
Implement an API using MySQL to store objects
Author: By
Last change:
Date: 22 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;
    }
});

?>