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

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to