Skip to content

Autoloading with Namespaces

Autoloading automatically loads class files when they are needed.

This avoids manually including files.

spl_autoload_register(function ($class) {
$path = str_replace("\\", "/", $class) . ".php";
require $path;
});