<?php
abstract class ParentP {
abstract public function doMaths($num); //returns int
public function getMagicNumber()
{
return 50;
}
}
class IMultiply extends ParentP {
public function doMaths($num) { echo static::getMagicNumber() * $num; }
}
class IAdd extends ParentP {
public function doMaths($num) { echo $this->getMagicNumber() + $number; }
}
$a = new IMultiply;
$a->doMaths(2);
// -----
$b = new IAdd;
$b->doMaths(2);