note 113047 added to language.oop5.traits
| From: | StefanW | Date: | Thu, 22 Aug 2013 10:03:23 +0000 |
| Subject: | note 113047 added to language.oop5.traits | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-196049@lists.php.net to get a copy of this message | ||
Note that the "use" operator for traits (inside a class) and the "use" operator
for namespaces (outside the class) resolve names differently. "use" for namespaces always
sees its arguments as absolute (starting at the global namespace):
<?php
namespace Foo\Bar;
use Foo\Test; // means \Foo\Test - the initial \ is optional
?>
On the other hand, "use" for traits respects the current namespace:
<?php
namespace Foo\Bar;
class SomeClass {
use Foo\Test; // means \Foo\Bar\Foo\Test
}
?>
Together with "use" for closures, there are now three different "use" operators.
They all mean different things and behave differently.
----
Server IP: 212.124.37.9
Probable Submitter: 213.47.132.228
----
Manual Page -- http://php.net/manual/en/language.oop5.traits.php
Edit -- https://master.php.net/note/edit/113047
Del: integrated -- https://master.php.net/note/delete/113047/integrated
Del: useless -- https://master.php.net/note/delete/113047/useless
Del: bad code -- https://master.php.net/note/delete/113047/bad+code
Del: spam -- https://master.php.net/note/delete/113047/spam
Del: non-english -- https://master.php.net/note/delete/113047/non-english
Del: in docs -- https://master.php.net/note/delete/113047/in+docs
Del: other reasons-- https://master.php.net/note/delete/113047
Reject -- https://master.php.net/note/reject/113047
Search -- https://master.php.net/manage/user-notes.php