Here is the simple php code
<?
abstract class A{
abstract public function a($x);
}
class B extends A{
public function a($x)
{
echo $x;
}
}
$q = new B;
$q->a(10);
?>
which gives:
PHP Fatal error: Cannot call abstract method A::a()
but changing the name of the function to something else than “a” works.
So what is really happening with the call to a(10) ?
I don’t see the logic here.
You got a pretty obvious problem. Since you don’t have a
__construct()method, theabstract public function a();is your constructor (php 4). Your fatal error fires when instantiating the B class, and not when calling methoda()on the instance of B class.If you change the name of your method
a()in something else, all works as intended!Example that works: