这是我正在尝试做的一个例子。任何关于最佳实践的帮助都会非常有帮助!
<?php
$fullprice = "5990";
$discount = "30"; // This is 30 percentage
echo = $fullprice - $discount; // Here i need to deduct 30% from the fullprice ?
?>
这是我正在尝试做的一个例子。任何关于最佳实践的帮助都会非常有帮助!
<?php
$fullprice = "5990";
$discount = "30"; // This is 30 percentage
echo = $fullprice - $discount; // Here i need to deduct 30% from the fullprice ?
?>
echo $fullprice * ((100 - $discount) / 100);
$fullprice = 5990;
$discount = 30; // This is 30 percentage
echo $fullprice * ((100 - $discount) / 100);
echo $fullprice * (1 - $discount/100);
白痴证明折扣价格计算:
$fullPrice * (100 - max(0, min(100, $discount))) / 100;
它将折扣百分比压缩在 0 到 100(含)之间。