Guys I'm facing a problem by using spl_autoload_register function. What I'm using is XAMPP in its htdocs directory there is another directory called boot. This directory has 2 files a Car class file and just a Main php file. That class using namespace boot. I want to load that class by using this function spl_autoload_register but error is coming like this. What I'm doing wrong.
Warning: require(boot\Car.php): failed to open stream: No such file or directory in C:\xampp\htdocs\boot\Main.php
Code Car.php
<?php
namespace boot;
class Car
{
public function __construct()
{
echo 'Constructor has been created!';
}
}
Code Main.php
<?php
spl_autoload_register(function ($className){
require $className . '.php';
});
use boot\Car;
$car = new Car;