3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Katana { private $description = 'The katana is characterized by its distinctive appearance: a curved, single-edged blade with a circular or squared guard and long grip to accommodate two hands. Western historians have said that katana were among the finest cutting weapons in world military history.'; private $damage = 30; public function applyDamage() { $damageOutput = $this->damage; // 5% chance of a critical hit. Double the damage. $criticalHit = random_int(1, 100); if ($criticalHit < 5) { $damageOutput *= 2; } return $damageOutput; } public function description() { return $this->description; } } $weapon = new Katana; echo $weapon->applyDamage();
Output for 7.1.0 - 7.1.16, 7.1.25, 7.2.0 - 7.2.13, 7.3.0 - 7.3.1
30
Output for 7.1.17
60

preferences:
67.94 ms | 401 KiB | 40 Q