, __autoload() , , ; spl_autoload_register() :
//first define a custom function
function myAutoLoader( $className ){
$path = strtolower( path/to/your/class/ . $className . '.php' );
include_once( $path );
}
, strtolower() $className. , , ( ) ( ). ( Windows) , . , , Windows, (debian) .
spl_autoload_regsiter. , -
//Now use spl_autoload_register()
spl_autoload_register( 'myAutoLoader' );
, - , :
//first define a custom function with exception handling
function myAutoLoader( $className ){
$path = strtolower( path/to/your/class/ . $className . '.php' );
include_once( $path );
if( !class_exists( $className, false ) ){
throw new RuntimeException( 'Class '. $className . ' has not been
loaded yet' );
}
}
//then the spl_autoload_register(), just like before
spl_autoload_register( 'myAutoLoader' );
.