php oop extends problem

forwhat84

New Member
i have the following classes.\[code\]class base { private function __construct(){ //check if foo method exists //$this->foo(); // if it exists } public static function singleton(){ if(!isset(self::$singleton)){ self::$singleton = new base(); } return self::$singleton; }}class sub extends base{ public function __construct() { parent::singleton(); } public function foo(){ }}\[/code\]then init it like so \[code\]$test = new sub();\[/code\]my problem is that I want to check on \[code\]base __construct\[/code\] if the sub has a \[code\]foo\[/code\] method.but it doesn't seem to have this method.can someone tell me where have I gone wrong?
 
Back
Top