Re: [php 5] static class variable question

From: Date: Tue, 06 Apr 2004 18:59:38 +0000
Subject: Re: [php 5] static class variable question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-182522@lists.php.net to get a copy of this message
A note: > by creating a class called myProject and having Audio and System be static > variables, referring to the classes Audio and System. The Audio and System This should be constant, not static. Sorry. -bill "Bill Zeller" <bill@zempt.com> wrote in message news:20040406184921.59338.qmail@pb1.pair.com... > [PHP5 RC1, Windows XP Pro] > Hi, > > I have a few classes called Audio, System, etc. In order to not pollute the > namespace (if someone else has a System class, for example), I'd like to > separate my classes. One way of doing this would be to preprend each class > with some text, to make my classes something like "myProject_Audio", > "myProject_System", "myProject_Whatever". I would much rather be able to do > something like myProject::Audio, myProject::System. I would like to do this > by creating a class called myProject and having Audio and System be static > variables, referring to the classes Audio and System. The Audio and System > variables in class myProject would act as an alias to the Audio and System > classes. > > I can access myProject::someVar fine when someVar is any variable, but I'm > unable to call: > > $audio = new myProject::Audio; > > Is there any way to do this? Should I create a static function Audio() in > class myProject and forward the variables to the Audio class? If I did that > I could call > > $audio = new myProject::Audio(); or > $audio = new myProject::Audio("var1", "var2"); > > but then it would be hard to access variables in class Audio (because you > can't do myProject::Audio()::someVarInAudio because "Parse error: parse > error, unexpected T_PAAMAYIM_NEKUDOTAYIM") > > Thanks, > > Best Regards, > Bill Zeller

« previous php.general (#182522) next »