"use ProjectA;" is equivalent of "use ProjectA as ProjectA;"
if you want to use something from namespace you should "use" that something. for example: "use ProjectA::BOOK;" On 1/10/08, Tomi Kaistila <[EMAIL PROTECTED]> wrote: > Sorry for the ambiguous subject line, but I could not find a better wording > for it. > > Currently, when you use namespaces in PHP, whenever you want to call a > function from inside a namespace you must either use the entire name of the > namespace (potentially very long) or give it a shorter alias. > > Here is an example: > > namespace.inc > > namespace ProjectA; > const WORD = 'foobar'; > > execute.php > use ProjectA as A; > print A::WORD; > > This works out fine. But when I change the two last lines in execute.php to: > > use ProjectA; > print WORD; > > I get a warning saying "The use statement with non-compound name 'ProjectA' > has no effect ..." and naturally also a notice about using a non-defined > constant. > > So, the default namespace in use, is always global. What about if the default > could be changed? It would put to rest the need to always specify the > namespace from which to look for the function or class. This would mean that > the last example of execute.php would be valid. You could also still access > the global space with the following syntax: > > execute.php > const BOOK = 'Two Towers'; > use ProjectA; > print ::BOOK; > > Any thoughts on this? Was this sort of approach considered when the namespaces > were being implemented? > > Tomi Kaistila > PHP Developer > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Alexey Zakhlestin http://blog.milkfarmsoft.com/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php