[thelist] basic OO php question
Rick den Haan
rick.denhaan at gmail.com
Wed Apr 18 05:59:58 CDT 2007
Mattias Thorslund wrote:
> > function X()
> > {
> > $y = new Y();
> >
> //Not sure if this matters to you but $y goes immediately out of scope
> and is not used for anything.
>
> > }
I know, but this is just a bare example containing just the problem. The
real class is a lot bigger (and better named), where stuff happens to
variables.
> > function Y()
> > {
> > echo parent::$foo;
> >
> echo X::foo; //not sure if class variables work, but if not, this would:
>
> $oX = new X();
> echo $oX->foo;
>
> > // Doesn't work, because Y does not extend X, but I want this to
> > output "bar"
> > }
That would work, but there are things happening to the real class (X) that
change certain class variables I need in Y. But referencing X as kasimir-k
suggested does the trick.
Thanks,
Rick.
More information about the thelist
mailing list