Why namespace is passed to spl_autoload_register and how can I get rid of it?

I’m currently doing this but it doesn’t look right to me:

spl_autoload_register(function ($class_name){
    $class_name = str_replace('MyNameSpace\\\\', '', $class_name . '.php');

    require $class_name;
});

Please advise.

The namespace is passed so you can apply whatever logic you need to load the required librar(y|ies), and what you’re doing looks okay to me (ie. applying your own specific logic). My advice, take a look at PSR-0 and see how the implementation differs to your own.

Anthony.