php - Back slash to get name space -
so, in router.php file create object of runapp
class using namespace. work fine.
namespace router; // app/routes.php $runapp= new \core\runapp();
in case slash(new \core\runapp()) means need namespace router
, try find runapp
class in core
namespace.
but also, can use link in way:
namespace router; use core\runapp; // app/routes.php $runapp= new runapp();
but, why in last case not need set \
befor namespace(use core\runapp)??
note namespaced names (fully qualified namespace names containing namespace separator, such foo\bar opposed global names not, such foobar), leading backslash unnecessary , not recommended, import names must qualified, , not processed relative current namespace.
from php - using namespaces: aliasing/importing
when use use
keyword, namespaces not relative, have qualified.
whereas, in other cases, it's relative current namespace.
Comments
Post a Comment