I have a parent class:
class parent{
var $a = 'param1';
var $b = 'param2';
public summary(){
if($this->a<0 || $this->b<0)
return FALSE;
return $this->a+$this->b;
}
public set_null(){
$this->a = null;
$this->a = null;
}
}
I need to prevent the summary method from overriding in child class, maybe my team doesn't know if summary method exists before.
class child extends parent{
public summary(){
return $this->a+$this->b;
}
public set_null(){
$this->a = 0;
$this->b = 0;
}
}
Can anyone help me with this problem?
You can do it using final modifier before summary() method definition in your parent class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With