I get this example from
http://www.php.net/manual/ru/function.spl-autoload.php#92767
But this causes an error
*Fatal error: spl_autoload() [function.spl-autoload]: Class space could not be loaded in C:\my_projects\site.local\www\index.php on line 18*
/index.php
// Your custom class dir
define('CLASS_DIR', 'oop/classes');
// Add your class dir to include path
set_include_path(get_include_path().PATH_SEPARATOR.CLASS_DIR);
// You can use this trick to make autoloader look for commonly used "My.class.php" type filenames
spl_autoload_extensions('.class.php');
// Use default autoload implementation
spl_autoload_register();
new space/my;
/oop/classes/space/my.class.php
namespace space;
class my{
public function __construct{
var_dump('space class was here!');
}
}
I know about PSR-0, but in my case I need to understand how built function works
should be
Note: you missed
()of the__constructinmy.class.php