Re: Namespace

From: Date: Sat, 08 Dec 2007 21:23:24 +0000
Subject: Re: Namespace
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-33874@lists.php.net to get a copy of this message
Once you say "namespace xyz ;" everything in the file is now relative to namespace xyz. To refer to the global namespace, you use the following <?php namespace xyz ; function substr() { return true ; } substr(); // calls substr in current namespace ::substr(); // calls substr in global namespace ?> On Sat, 2007-12-08 at 20:12 +0000, Richard Quadling wrote: > On 07/12/2007, Lokrain <lokrain@gmail.com> wrote: > > Hello all, > > > > I just wanted to drop an opp. Just to see the logic, when we have > > programming structure class, interface, function, if statement, switch > > statement etc, we have bracers encapsulation. This is the logic that most > > programming language give to show a programmer that something is inside > > something. We here have namespace with the same idea, and no bracers. > > > > Conclusion: namespaces are not logical => no thanks > > > > PS. By the way, I do not think that any workarounds on that logic will not > > be nice. > > > > I'm trying to understand the argument against using braces. > > And that has led me to the following question. > > Assuming no braces, how would I put code OUTSIDE of the namespace in a > single file. > > <?php > namespace XYZ; > > xyz related code goes here > > non xyz related code goes here but how do I let PHP know it isn't part of xyz? > > > > Do I have to change namespace by using a dummy namespace? Same issue > how do I refer to the global namespace. > > > Richard. > > -- > ----- > Richard Quadling > Zend Certified Engineer : > http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!" >

« previous php.internals (#33874) next »