PHP Classes

File: example/autoload.php

Recommend this page to a friend!
  Classes of Jorge Castro   Security One Mysql   example/autoload.php   Download  
File: example/autoload.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Security One Mysql
Implement a login page for users in a MySQL table
Author: By
Last change:
Date: 27 days ago
Size: 2,598 bytes
 

Contents

Class file image Download
<?php
/**
 * This class is used for autocomplete.
 * Class _AUTOLOAD_
 * @noautoload it avoids to index this class
 * @generated by AutoLoadOne 1.15 generated 2019/06/08 10:03:46
 * @copyright Copyright Jorge Castro C - MIT License. https://github.com/EFTEC/AutoLoadOne
 */
$s5cfbb2323e6f3__debug = true;

/* @var string[] Where $_arrautoloadCustom['namespace\Class']='folder\file.php' */
$s5cfbb2323e6f3__arrautoloadCustom = [

];

/* @var string[] Where $_arrautoload['namespace']='folder' */
$s5cfbb2323e6f3__arrautoload = [

];

/* @var boolean[] Where $_arrautoload['namespace' or 'namespace\Class']=true if it's absolute (it uses the full path) */
$s5cfbb2323e6f3__arrautoloadAbsolute = [
 
];

/**
 * @param $class_name
 * @throws Exception
 */
function s5cfbb2323e6f3__auto($class_name)
{
   
// its called only if the class is not loaded.
   
$ns = dirname($class_name); // without trailing
   
$ns = ($ns == '.') ? '' : $ns;
   
$cls = basename($class_name);
   
// special cases
   
if (isset($GLOBALS['s5cfbb2323e6f3__arrautoloadCustom'][$class_name])) {
       
s5cfbb2323e6f3__loadIfExists($GLOBALS['s5cfbb2323e6f3__arrautoloadCustom'][$class_name], $class_name);
        return;
    }
   
// normal (folder) cases
   
if (isset($GLOBALS['s5cfbb2323e6f3__arrautoload'][$ns])) {
       
s5cfbb2323e6f3__loadIfExists($GLOBALS['s5cfbb2323e6f3__arrautoload'][$ns] . '/' . $cls . '.php', $ns);
        return;
    }
}

/**
 * We load the file.
 * @param string $filename
 * @param string $key key of the class it could be the full class name or only the namespace
 * @throws Exception
 */
function s5cfbb2323e6f3__loadIfExists($filename, $key)
{
    if (isset(
$GLOBALS['s5cfbb2323e6f3__arrautoloadAbsolute'][$key])) {
       
$fullFile = $filename; // its an absolute path
       
if (strpos($fullFile, '../') === 0) { // Or maybe, not, it's a remote-relative path.
           
$oldDir = getcwd(); // we copy the current url
           
chdir(__DIR__);
        }
    } else {
       
$fullFile = __DIR__ . "/" . $filename; // its relative to this path
   
}
    if ((@include
$fullFile) === false) {
        if (
$GLOBALS['s5cfbb2323e6f3__debug']) {
            throw new
Exception("AutoLoadOne Error: Loading file [" . __DIR__ . "/" . $filename . "] for class [" . basename($filename) . "]");
        } else {
            throw new
Exception("AutoLoadOne Error: No file found.");
        }
    } else {
        if (isset(
$oldDir)) {
           
chdir($oldDir);
        }
    }
}

spl_autoload_register(function ($class_name) {
   
s5cfbb2323e6f3__auto($class_name);
});
// autorun