PHP Classes

File: include/classAutoloader.inc.php

Recommend this page to a friend!
  Classes of Milan Jankovic   PHP PDO Starter Template   include/classAutoloader.inc.php   Download  
File: include/classAutoloader.inc.php
Role: Auxiliary script
Content type: text/plain
Description: Autoloader script
Class: PHP PDO Starter Template
Setup MySQL database connections using PDO
Author: By
Last change:
Date: 2 days ago
Size: 344 bytes
 

Contents

Class file image Download
<?php
namespace Include;

spl_autoload_register(function($className) {
   
$path = __DIR__ . '/../classes/';
   
$fullPath = $path . str_replace('\\', '/', $className) . '.class.php';
   
    if (
file_exists($fullPath)) {
        require_once
$fullPath;
    } else {
        throw new \
Exception("Unable to load class: $className");
    }
});