However, there are times where you might want to make
sure that a method cannot be re-implemented in its derived
classes. For this purpose, PHP supports the Java-like final
access modifier for methods that declares the method as
the final version, which can’t be overridden.
The following example is not a valid PHP script because it is trying to
override a finalmethod:
class MyBaseClass {
final function idGenerator()
{
return $this->id++;
}
protected $id = 0;
}
class MyConcreteClass extends MyBaseClass {
function idGenerator()
{
return $this->id += 2;
}
}
INHERITANCE OF INTERFACES
Interfaces may inherit from other interfaces. The syntax is
similar to that of classes, but allows multiple inheritance:
interface I1 extends I2, I3, ... {
...
}
Similar to when classes implement interfaces, an interface can only
extend other interfaces if they don’t clash with each other which means that
you receive an error if I2defines methods or constants already defined by I1.