What potential pitfalls should be considered when calculating customer discounts in PHP?

When calculating customer discounts in PHP, potential pitfalls to consider include ensuring that the discount amount is applied correctly to the total price, handling different types of discounts (percentage-based, fixed amount, etc.), and validating the discount input to prevent errors or misuse.

// Example of calculating customer discounts in PHP
$totalPrice = 100; // Total price of the items
$discountAmount = 10; // Discount amount in percentage

// Calculate the discounted price
$discountedPrice = $totalPrice - ($totalPrice * ($discountAmount / 100));

echo "Discounted price: $" . number_format($discountedPrice, 2);