> -----Ursprüngliche Nachricht----- > Von: Sam Barrow [mailto:[EMAIL PROTECTED] > Gesendet: Montag, 10. Dezember 2007 22:48 > An: internals@lists.php.net > Betreff: [PHP-DEV] Namespace resolution > > Ok, it's supposed to be this way right? If i define a custom class in > the global namespace called "myClass" and I'm in another namespace, I > can only access it using ::myClass, not just myClass (without the > colons)? Seems to me that it should check the local namespace and then > the global, but it only checks the globl if i specifically tell it to > with the preceding "::".
>From http://www.php.net/manual/en/language.namespaces.rules.php: -- Inside namespace (say A::B), calls to unqualified class names are resolved at run-time. Here is how a call to new C() is resolved: 1. It looks for a class from the current namespace : A::B::C(). 2. It tries to find and call the internal class C(). 3. It attemts to autoload A::B::C(). C(). To reference a user defined class in the global namespace, new ::C() has to be used. -- Which is exactly what you observed. -mp. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php