* Thus wrote Rudy Metzger ([EMAIL PROTECTED]):
> Dear all,
>
> I have a problem with 'referencing' static attributes. I have the
> following class tree.
>
> // --- CLASS A -
> class A
> {
> protected static $myInstance;
> }
>
> // --- CLASS B --
> class B extends class A
> {
> }
>
> // --- CLASS C --
> class C extends class B
> {
>
> public function Debug()
> {
> echo self::$myInstance; // does not work (undefined)
> echo parent::$myInstance; // also does not work
> echo A::$myInstance; // works
> }
>
> }
>
> -
> The Problem is that you always have to know in which class the static
> was defined to reference it. Or is there something like
> static::$myInstance or this::$myInstance or class::$myInstance. If not,
> it maybe would be a great idea to add something to PHP, otherwise you
> always have to track in which class the static had been defined if you
> want to reference it!
What version of php are you using? It appears to work with RC1 to
CVS version. The actual result I get is:
public function Debug() {
echo self::$myInstance; // works
echo parent::$myInstance; // error: Cannot access protected property
echo A::$myInstance; // error: Cannot access protected property
}
Its expected for the errors on the last two since you're accessing
the protected variable from outsite the public scope of Debug().
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php