Re: namespace equivalent in PHP
| From: | Jochem Maas | Date: | Wed, 07 Mar 2007 13:13:30 +0000 |
| Subject: | Re: namespace equivalent in PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-249968@lists.php.net to get a copy of this message | ||
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,
>