Why can't you call abstract functions from abstract classes in PHP?
Posted
by incrediman
on Stack Overflow
See other posts from Stack Overflow
or by incrediman
Published on 2010-05-18T17:42:21Z
Indexed on
2010/05/18
17:50 UTC
Read the original article
Hit count: 303
I've set up an abstract parent class, and a concrete class which extends it. Why can the parent class not call the abstract function?
//foo.php
<?php
abstract class AbstractFoo{
abstract public static function foo();
public static function getFoo(){
return self::foo();//line 5
}
}
class ConcreteFoo extends AbstractFoo{
public static function foo(){
return "bar";
}
}
echo ConcreteFoo::getFoo();
?>
Error:
Fatal error: Cannot call abstract method AbstractFoo::foo() in foo.php on line 5
© Stack Overflow or respective owner