This is a discussion on namespace equivalent in PHP within the PHP General forums, part of the PHP Programming Forums category; Hi, Coming from C++ world, i would like to know what in PHP, is the equivalent of namespace in C++ ? ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
Coming from C++ world, i would like to know what in PHP, is the equivalent of namespace in C++ ? I have several class which should work together, or Class B which is used to create a private property of class A. How can i do that without including the class B into the class A definition ? thanks a lot, -- Alain ------------------------------------ Windows XP SP2 PostgreSQL 8.1.4 Apache 2.0.58 PHP 5 |
|
|||
|
Alain Roger wrote:
> Hi, > > Coming from C++ world, i would like to know what in PHP, is the equivalent > of namespace in C++ ? the closest you get to a namespace is a class (used purely as a static place holder for a set of functions, constants & variables). namespaces is on the php dev list of things to have continuing discussions/flamewars about but as such no one has yet agreed on the correct implementation and/or whether to include it. I do remember a chap named Jesse created a patch that implements namespaces, actually I recall that he wrote a stack of different patches related to various namespace implementations - you'd have to search for them (and the relevant discussions on the internals mailing list) in order to determine if they are a viable option for you. > I have several class which should work together, or Class B which is > used to > create a private property of class A. > > How can i do that without including the class B into the class A definition > ? er, you don't, at least not with vanilla php. :-/ which leaves the question to why you want to do this, maybe there is a simpler alternative. it might simply be down to letting go of [your] C++ mindset somewhat and just living with less structured/rigid/er? code in php ... not that I know anything about C++ (and not meaning any insult) > > thanks a lot, > |
|
|||
|
On Wed, March 7, 2007 8:03 am, Alain Roger wrote:
> Coming from C++ world, i would like to know what in PHP, is the > equivalent > of namespace in C++ ? Nothing. Closest we have is wrapping yet another class around everything. PHP is a "simple" language, on purpose. C++ is a lot of things, but "simple" is not one of them. :-) -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? |