diff options
author | Mathew Peterson <mathewpeterson@sparknet.net> | 2011-05-27 11:48:44 -0500 |
---|---|---|
committer | Mathew Peterson <mathewpeterson@sparknet.net> | 2011-05-27 11:51:18 -0500 |
commit | 75d94d2e6e70d8cb26428fcfa5089b3b5059fdf7 (patch) | |
tree | 99d51c88be44bfdb0a1c395f594f2af39f8deceb /autoload.php | |
parent | 54c6d5bf2044684c0289453515d2bed42091dd5a (diff) | |
download | php-smpp-75d94d2e6e70d8cb26428fcfa5089b3b5059fdf7.zip php-smpp-75d94d2e6e70d8cb26428fcfa5089b3b5059fdf7.tar.gz php-smpp-75d94d2e6e70d8cb26428fcfa5089b3b5059fdf7.tar.bz2 |
Recreated autoloader function using php's spl_autoloader functionality.
Diffstat (limited to 'autoload.php')
-rwxr-xr-x[-rw-r--r--] | autoload.php | 24 |
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'); + |