PHP Classes

File: autoloader.php

Recommend this page to a friend!
  Classes of Stefan Kientzler   Complex PHP Form Design and Generator   autoloader.php   Download  
File: autoloader.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Complex PHP Form Design and Generator
Display and process complex HTML forms HTML forms
Author: By
Last change:
Date: 3 years ago
Size: 679 bytes
 

Contents

Class file image Download
<?php
function autoRegister(string $strClassName) : void
{
   
$strInclude = '';
    if (
strpos($strClassName, '\\') > 1) {
       
// replace the namespace prefix with the base directory, replace namespace
        // separators with directory separators in the relative class name, append
        // with .php
       
$strInclude = str_replace('\\', DIRECTORY_SEPARATOR, $strClassName) . '.php';
    }

   
// if the file exists, require it
   
if (strlen($strInclude) > 0) {
       
$strInclude = dirname(__FILE__) . '/' . $strInclude;
        if (
file_exists($strInclude)) {
            require
$strInclude;
        }
    }
}

spl_autoload_register('autoRegister');