Direct Instantiation Works: When you use new AdminController() directly, PHP understands that AdminController refers to the class within the current namespace (Base) because of the namespace declaration at the top of the file.
Dynamic Instantiation Requires Fully Qualified Namespace: When you assign $class = "AdminController" and then use new $class(), PHP does not automatically assume that AdminController is in the Base namespace. It will look for AdminController in the global namespace unless you explicitly specify the namespace.
namespace Base; class Router { function loadClass($class) { require_once "$class.php"; $class = "Base Admin\\Controller"; $obj = new $class(); $obj = new AdminController(); } }