3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Yoba { private int $age; public function getAge () : int { return $this->age; } public function setAge (int $age) : void { if (!$this->ageIsValid($age)) { throw new Exception("0 < \$age <= 100, passed " . $age); } $this->age = $age; } public function ageIsValid (int $age) : bool { if (($age > 0) && ($age <= 100)) { return true; } return false; } } $yo = new Yoba(); $yo->setAge(10); echo $yo->getAge(); $yo->setAge(1000); echo $yo->getAge();

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
158.51 ms | 1619 KiB | 8 Q