function get_buy_cost($id = false) { $id or $id = $this->get_id(); $db = new db_alloc(); $q = prepare("SELECT amount, currencyTypeID, tax\n FROM productCost\n WHERE isPercentage != 1\n AND productID = %d\n AND productCostActive = true\n ", $id); $db->query($q); while ($row = $db->row()) { if ($row["tax"]) { list($amount_minus_tax, $amount_of_tax) = tax($row["amount"]); $row["amount"] = $amount_minus_tax; } $amount += exchangeRate::convert($row["currencyTypeID"], $row["amount"]); } return $amount; }
<?php //Note: the & in front of $salary causes the variable to be passed as a reference //function tax($salary) { function tax(&$salary) { $salary = $salary - 500; //$salary -= 500; return $salary; } $salary = 2500; echo tax($salary); echo "<br>{$salary}";