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();

preferences:
21.01 ms | 402 KiB | 5 Q