Last active
August 29, 2015 14:14
-
-
Save derpixler/2903b4ca6879a5d9b2f8 to your computer and use it in GitHub Desktop.
php autoloader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace autoloader; | |
function _autoload( $is_admin = false ){ | |
if( $is_admin == 1 ) | |
$is_admin = 'admin/'; | |
foreach ( glob( self::$plugin_obj->include_path . $is_admin . '*.class.php' ) as $k => $file ) { | |
$s = self::$plugin_obj->include_path . $is_admin . "(#.*?).class.php"; | |
preg_match_all( '/' . str_replace( array( '/', '.', '#\.' ), array( '\/', '\.', '.' ), $s ) . "$/" , $file, $match ); | |
require_once( $match[0][0] ); | |
$class = __NAMESPACE__ . '\\' . $match[1][0]; | |
new $class(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment