Re: Changes in namespace importing

From: Date: Fri, 24 Nov 2017 13:21:17 +0000
Subject: Re: Changes in namespace importing
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-101152@lists.php.net to get a copy of this message
On 24 November 2017 07:05:52 GMT+00:00, "Khawer ." <khaweronline@gmail.com> wrote: >We use 'use' keyword to import other namespaces, namespace classes, >namespace functions, and namespace constants. > >Example >1) use abc; (Import abc namespace) >2) use abc\ClassB; (Import ClassB from abc namespace) Although these are described in the manual as separate types of import, they are actually the same: they alias a prefix used to rewrite class names when you mention them. If you have a class "One\Two\Test" and a class "One\Two", then "use One\Two" will allow you to access them as "Two\Test" and "Two", respectively. https://3v4l.org/nQ7pB Similarly, if you alias a prefix with "use Foo as Bar", then "new Bar\Test" will refer to class "Foo\Test", and "new Bar" will refer to class "Foo". https://3v4l.org/2r6WN So "use class" wouldn't make sense, because that's not actually what happens. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#101152) next »