Does not create a class instance from a string that contains the namespace and class name. If you do not use USE everything works, but does not want to use USE
Рабочий вариант: <?php namespace SE_Core\Test; class Main { public function show() { } } $className = 'Main'; $class = 'SE_Core\Test\\' . $className; $obj = new $class(); print_r($obj); ?> Нерабочий вариант: <?php namespace SE_Core\Test; use SE_Core\Test as SE; class Main { public function show() { } } $className = 'Main'; $class = 'SE\\' . $className; $obj = new $class(); print_r($obj); ?>
useis just an alias. But in general, why use the full names found in the same namespace is the question. Yes, and do alias to the current space. Especially since thisuseis valid only within the framework of this file, that is, transferring it will not work anywhere. - teran