You can’t access $dine in your second function because it’s nowhere defined. The $dine from your first function is only a local variable.
I would suggest this solution which uses the fact that calculate_dinein_price() also returns the value of $dine:
public function calculate_dinein_total(){
$total_dine = 0.00;
$total_dine = $total_dine + $this->calculate_dinein_price();
return $total_dine;
}
8
solved Php Calculating two functions [closed]