3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Example { protected $attributes = []; public string $email { get => $this->attributes['email']; set => $this->attributes['email'] = strtolower($value); } } $example = new Example; $example->email = 'should only appear once'; var_dump($example);
Output for 8.4.1 - 8.4.6
object(Example)#1 (2) { ["attributes":protected]=> array(1) { ["email"]=> string(23) "should only appear once" } ["email"]=> string(23) "should only appear once" }
Output for 8.2.0 - 8.2.28, 8.3.0 - 8.3.20
Parse error: syntax error, unexpected token "{", expecting "," or ";" in /in/fgmvY on line 7
Process exited with code 255.

preferences:
162.67 ms | 1072 KiB | 8 Q