A function that calculates sales tax
<?
$price = 4.9;
$tax = .04;
function calculate_cost($tax, $price) {
$sales_tax = $tax;
return $price + ($price * $sales_tax);
}
$total_cost = calculate_cost ($tax, $price);
$total_cost = round($total_cost, 2);
print "Total cost: ".$total_cost;
?>
Related examples in the same category