namespace equivalent in PHP

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++ ? ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-07-2007
Alain Roger
 
Posts: n/a
Default namespace equivalent in PHP

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

Reply With Quote
  #2 (permalink)  
Old 03-07-2007
Jochem Maas
 
Posts: n/a
Default Re: [PHP] namespace equivalent in PHP

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

Reply With Quote
  #3 (permalink)  
Old 03-13-2007
Richard Lynch
 
Posts: n/a
Default Re: [PHP] namespace equivalent in PHP

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?
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:48 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0