From 4f102cdd2adc56b05fbf68b6f19f1b263612047b Mon Sep 17 00:00:00 2001 From: Stricted Date: Thu, 7 Nov 2013 01:00:42 +0100 Subject: [PATCH] add autoload class --- autoload.class.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 autoload.class.php diff --git a/autoload.class.php b/autoload.class.php new file mode 100644 index 0000000..a12ea1d --- /dev/null +++ b/autoload.class.php @@ -0,0 +1,44 @@ +. + */ +class autoload { + /* + * constructor to set autoloader + */ + public function __construct () { + spl_autoload_register(array('self', 'autoload')); + } + + /* + * autoload class files from namespace uses + * + * @param string $className + */ + public static function autoload ($className) { + $namespaces = explode('\\', $className); + if (count($namespaces) > 1) { + array_shift($namespaces); + $classPath = dirname(__FILE__) . '/' . implode('/', $namespaces) . '.class.php'; + if (file_exists($classPath)) { + require_once($classPath); + } + } + } +} +new autoload(); +?> \ No newline at end of file -- 2.20.1