3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Button { public string $text = ''; public string $type = 'button' { set { echo 'setting ' . $value; $this->type = $value; } } } $var = new Button(); $var->text = 'hey'; $var->type = 'bazongas'; print_r($var);
Output for 8.4.1 - 8.4.3
setting bazongasButton Object ( [text] => hey [type] => bazongas )
Output for 8.2.0 - 8.2.27, 8.3.0 - 8.3.16
Parse error: syntax error, unexpected token "echo" in /in/XSFSQ on line 9
Process exited with code 255.

preferences:
149.92 ms | 954 KiB | 7 Q