The PHP code I'm trying to write, however, will be the equivalent of this:
public class Foo {
public Foo() {
doSomethingNonStaticHere();
}
public static final String[] fooArray = "{'blah', 'whatever', 'etc.'}";
public static String getFooValue(int i) {
return fooArray[i];
}
public void doSomethingNonStaticHere() {
// BLAH BLAH BLAH
System.out.println("Blah blah blah");
}
}
out.println(Foo.getFooValue(1));
Phil
Daniel Tryba <news_comp.lang.php@canopus.nl> wrote in message news:<c6kegl$cpn$1@news.tue.nl>...[color=blue]
> Phil Powell <soazine@erols.com> wrote:[color=green]
> > I might have found a rather bad hole in PHP OO design for Versions
> > 4.3.2 involving static class-level rendering, like in Java. Please
> > read my thread at
http://www.phpbuilder.com/board/show...7#post10505527[/color]
>[color=green]
> > and please, if you have a counter to this, I'm all ears. Based on
> > what I have found so far, nothing seems to address this, not even in
> > the manual.[/color]
>
> The PHP code you posted is equivalent to the following java code:
>
> class Foo
> {
> public static String foo="Foo";
>
> public static String bar()
> {
> return this.foo;
> }
> }
>
> IOW It doesn't work.
>
> And since you can't access a variable in a static way (in php4), there
> is no equivalent for:
> class Foo
> {
> public static String foo="Foo";
>
> public static String bar()
> {
> return Foo.foo;
> }
> }
>
> With
http://www.php.net/manual/en/functio...class-vars.php one can
> access the defaults but the example clearly shows that it's not the
> solution to your "problem".[/color]