I'm trying to implement what I think is called a "virtual method": my
abstract parent class ParentClass defines a method xxx that calls
method yyy, but yyy is defined only in ParentClass's children.
I can't get this to work (PHP5.0.4). Sample code:
=== start sample code ===
abstract class ParentClass {
// xxx just returns 5 + whatever yyy() returns
public static function xxx () {return 5 + yyy();}
// all my children must define yyy()
abstract static function yyy();
}
abstract class ChildClass extends ParentClass {
public static function yyy () {return 7;}
}
echo ChildClass::xxx();
=== end sample code ===
When I run the above, I get this error:
Fatal error: Call to undefined function yyy() in <file> on line 9
Changing the call from yyy() to self::yyy() gives a different error:
Fatal error: Cannot call abstract method ParentClass::yyy() in <file> on line 9
How to do this correctly?
--
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php