Re: AW: [PHP-DEV] Namespace resolution

From: Date: Wed, 12 Dec 2007 00:01:33 +0000
Subject: Re: AW: [PHP-DEV] Namespace resolution
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  Groups: php.internals 
Request: Send a blank email to internals+get-33949@lists.php.net to get a copy of this message
Am 12.12.2007 um 00:27 schrieb Stanislav Malyshev:
<example.php> require_once('setup.php'); import Name::Space; $d = new DateTime(); // a PHP DateTime someStuffWeDoNotHaveControlOver(); $d = new DateTime(); // a Name::Space::DateTime now!
Of course not. DateTime would be just DateTime there, not Name::Space::DateTime, since you are not inside namespace Name::Space but in global context.
Why? I did import Name::Space. According to the current lookup rules, the first new DateTime() call creates a PHP internal class since Name::Space::DateTime cannot be found (and autoloading would only be triggered later), and the second DateTime() call does create Name::Space::DateTime because by then, it has been autoloaded and thus can be found in the current namespace. David

« previous php.internals (#33949) next »