3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { const PROP_1 = 'prop'; const PROP_2 = 'more_prop'; private static $props = [ self::PROP_1, self::PROP_2, ]; public function setProp($prop) { if (!in_array($prop, self::$props)) { throw new InvalidArgumentException(); } $this->prop = $prop; } } $a = new A(); $a->setProp(0); var_dump($a);

preferences:
28.19 ms | 402 KiB | 5 Q