SHARE
TWEET

Untitled

a guest Sep 13th, 2017 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. spl_autoload_register(function ($strClass) {
  2.     $strFile = $strClass . '.php';
  3.     $strNameSpace = '';
  4.  
  5.     if (($iLast = strripos($strClass, '\\')) !== false) {
  6.         $strNameSpace = DS . str_replace('\\', DS, substr($strClass, 0, $iLast));
  7.         $strNameSpace = implode('_', preg_split('/(?<=[a-zA-Z])(?=[A-Z])/s', $strNameSpace));
  8.         $strFile = substr($strClass, $iLast + 1) . '.php';
  9.     }
  10.  
  11.     $strFilePath = ROOT . strtolower($strNameSpace) . DS . $strFile;
  12.     if (is_readable($strFilePath)) {
  13.         require_once $strFilePath;
  14.  
  15.         if (class_exists($strClass)) {
  16.             return true;
  17.         }
  18.     }
  19.  
  20.     return false;
  21. });
RAW Paste Data
Top