Posted by giacomo.galilei on 09/25/06 16:55
I have this piece of code:
abstract class Kaos
{
static $foo;
abstract function MyFunc();
}
...
$bar = "aaa";
class Kronos extends Kaos
{
function MyFunc() {
echo self::$foo;
}
}
Kronos::$foo = $bar;
...
$bar = "bbb";
class Zeus extends Kronos
{
function MyFunc() {
parent::MyFunc();
echo self::foo;
}
}
Zeus::$foo = $bar;
At this point i would like that this code to show "aaabbb", but it
shows "bbb";
$a = new Zeus();
$a -> MyFunc();
Why ? I think that i have misunderstood the meaning of 'static' keyword
for a class member, but i need a field that has the same name in each
class, but in the calls of Kronos (of a Zeus object) its value is "aaa"
and in the calls of Zeus its value is "bbb".
How can i do this ? Is possible ?
Thanks in advance
Bye
[Back to original message]
|