I have a few variables that I need to do some math on let's call them price, coupon, discount.
Generally speaking the formula would look like this (price - coupon - discount = newprice). How do I prevent PHP from returning a negative value if the sum of the coupon and discount is more than the price of the item?
I'm basically trying to compute the savings on a particular item after using a coupon and a store discount.
<?php
$price = $10;
$coupon = $5;
$discount = $6;
// This will return a - value but is actually a net gain of $1
$newprice = ($price - $coupon) - $discount;
echo $newprice;
?>