sum = $this->num + $this->cal($this->num, $this->num); } public function cal($top, $bottle) { if ($top >= $this->topUnit || $bottle >= $this->bottleUnit) { $this->leftTop = intval($top / $this->topUnit) + $top % $this->topUnit + intval($bottle / $this->bottleUnit); $this->leftBottle = intval($bottle / $this->bottleUnit) + $bottle % $this->bottleUnit + intval($top / $this->topUnit); $this->sum = intval($top / $this->topUnit) + intval($bottle / $this->bottleUnit) + $this->cal($this->leftTop, $this->leftBottle); return $this->sum; } else { return 0; } } public function __toString() { return (string) $this->sum; } } $c = new Drink(); echo $c;