blob: 9cbe99890ac1c7d053b4d5215c6a8db08d322c4a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<?php
function php_smpp_autoloader($name)
{
$parts = explode('\\',$name);
// Figure out where to load files from
$baseDir = strtolower($parts[0]);
// Construct path to where we expect file to be, using each subnamespace as a directory
$subnamespaces = array_slice($parts,1,-1);
$subnamespaceString = !empty($subnamespaces) ? (strtolower(implode(DIRECTORY_SEPARATOR,$subnamespaces)).DIRECTORY_SEPARATOR) : '';
$className = strtolower(end($parts));
$pathName = realpath( __DIR__ ) . DIRECTORY_SEPARATOR . $baseDir . DIRECTORY_SEPARATOR . $subnamespaceString;
if(file_exists($pathName.$className.'.class.php'))
{
require_once($pathName.$className.'.class.php');
}
return; // finally give up
}
spl_autoload_register('php_smpp_autoloader');
|