Skip to content

Instantly share code, notes, and snippets.

@derpixler
Last active August 29, 2015 14:14
Show Gist options
  • Save derpixler/2903b4ca6879a5d9b2f8 to your computer and use it in GitHub Desktop.
Save derpixler/2903b4ca6879a5d9b2f8 to your computer and use it in GitHub Desktop.
php autoloader
<?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