Created
November 6, 2011 14:35
-
-
Save robap/1342963 to your computer and use it in GitHub Desktop.
Better php class autoloading
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 | |
function load_one( $class_name ) | |
{ | |
$file = 'lib1/' . $class_name . '.php'; | |
if( file_exists($file) ) | |
{ | |
require_once $file; | |
} | |
} | |
function load_two( $class_name ) | |
{ | |
$file = 'lib2/' . $class_name . '.php'; | |
if( file_exists($file) ) | |
{ | |
require_once $file; | |
} | |
} | |
spl_autoload_register( 'load_one' ); | |
spl_autoload_register( 'load_two' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In PHP 5.3 you could even write