What are some best practices for loading classes in PHP namespaces and allowing access without explicitly declaring the namespace or using the "use" keyword?

When loading classes in PHP namespaces and allowing access without explicitly declaring the namespace or using the "use" keyword, one common approach is to use the PHP magic method `__autoload()` or the newer `spl_autoload_register()` function to dynamically load classes as needed. By defining a custom autoload function, you can map class names to their corresponding file paths and include them when the class is instantiated without needing to manually include or require the files.

spl_autoload_register(function($className) {
    $classPath = str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php';
    if (file_exists($classPath)) {
        require_once $classPath;
    }
});

// Now you can create instances of classes in namespaces without explicitly including them
$example = new Namespace\Example();