3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Calculator { /** * Calculate the discount percentage */ function getDiscount($price=0, $sale=0) { $difference = $price-$sale; $discount = ($difference/$price) * 100; if($discount>0) { return $discount; } } } $calculator = new Calculator(); echo $calculator->getDiscount(23,24); if($calculator->getDiscount(23,24)==null){ echo 'No discount'; } echo round(3.6);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
No discount4