3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CreateUserInput { #[Argument] public string $email { set(string $value) { $this->email = strtolower(trim($value)); } } #[Option] public array $roles = [] { set(array $value) { $this->roles = array_map('strtoupper', $value); } } } $a = new CreateUserInput; $a->email = ' FOO '; $a->roles = ['bar']; var_dump($a);
Output for 8.4.18, 8.5.3
object(CreateUserInput)#1 (2) { ["email"]=> string(3) "foo" ["roles"]=> array(1) { [0]=> string(3) "BAR" } }
Output for 8.3.30
Parse error: syntax error, unexpected token "{", expecting "," or ";" in /in/A5TJW on line 6
Process exited with code 255.

preferences:
44.6 ms | 489 KiB | 3 Q