summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]autoload.php24
1 files changed, 11 insertions, 13 deletions
diff --git a/autoload.php b/autoload.php
index ac9a6e2..9cbe998 100644..100755
--- a/autoload.php
+++ b/autoload.php
@@ -1,5 +1,6 @@
<?php
-function __autoload($name)
+
+function php_smpp_autoloader($name)
{
$parts = explode('\\',$name);
@@ -9,19 +10,16 @@ function __autoload($name)
// 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 = end($parts);
- $pathName = $baseDir . DIRECTORY_SEPARATOR . $subnamespaceString;
+ $className = strtolower(end($parts));
+ $pathName = realpath( __DIR__ ) . DIRECTORY_SEPARATOR . $baseDir . DIRECTORY_SEPARATOR . $subnamespaceString;
- // Try three common extensions .class.php, .interface.php and .php
- if (file_exists($pathName.strtolower($className).'.class.php')) {
- require_once($pathName.strtolower($className).'.class.php');
- } else if (file_exists($pathName.strtolower($className).'.interface.php')) { // also try .interface.php
- require_once($pathName.strtolower($className).'.class.php');
- } else if (file_exists($pathName.strtolower($className).'.php')) { // also try .php
- require_once($pathName.strtolower($className).'.php');
- } else {
- return;
+ if(file_exists($pathName.$className.'.class.php'))
+ {
+ require_once($pathName.$className.'.class.php');
}
return; // finally give up
-} \ No newline at end of file
+}
+
+spl_autoload_register('php_smpp_autoloader');
+