Re: namespace equivalent in PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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,
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux