Return to Snippet

Revision: 39740
at January 29, 2011 09:54 by kendsnyder


Updated Code
spl_autoload_register('autoloadByUnderscore');


function autoloadByUnderscore($class) {
	$pwd = dirname(__FILE__);
	$filename = str_replace('_','/',$class) . '.php';
	$path = "$pwd/../lib/$filename";
	if (is_file($path)) {
		require_once $path;
	}
}

// or rediculously simple:
function autoloadByUnderscore($c) {
	require_once(dirname(__FILE__) . '/../lib/' . str_replace("_", '/', $c) . '.php');
}

Revision: 39739
at January 20, 2011 07:03 by kendsnyder


Initial Code
spl_autoload_register('autoloadByUnderscore');


function autoloadByUnderscore($class) {
	$pwd = dirname(__FILE__);
	$filename = str_replace('_','/',$class) . '.php';
	$path = "$pwd/../lib/$filename";
	if (is_file($path)) {
		require_once $path;
	}
}

Initial URL

                                

Initial Description

                                

Initial Title
Zend Framework style autoloader

Initial Tags

                                

Initial Language
PHP