3v4l.org

run code in 500+ PHP versions simultaneously
<?php function calculateTotal(float $price, int $quantity, float $discount = 0.0): float { $total = $price * $quantity; $total = $total - ($total * $discount / 100); return $total; } echo calculateTotal(10000, 2) . " ₸<br>"; echo calculateTotal(15000, 3, 10) . " ₸<br>"; echo calculateTotal(5000, 4, 20) . " ₸<br>"; ?>
Output for 8.2.0 - 8.2.34, 8.3.0 - 8.3.35, 8.4.1 - 8.4.26, 8.5.0 - 8.5.11
20000 ₸<br>40500 ₸<br>16000 ₸<br>

preferences:
29.13 ms | 1155 KiB | 7 Q