3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait T { private int $a = 1; public function t() { var_dump($this->a); var_dump(get_object_vars($this)); } } class A { use T; } $a = new A(); $a->t();
Output for 7.4.3 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
int(1) array(1) { ["a"]=> int(1) }
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.33
Parse error: syntax error, unexpected 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/tmDYO on line 4
Process exited with code 255.
Output for 5.4.0 - 5.4.28, 5.5.0 - 5.5.12
Parse error: syntax error, unexpected 'int' (T_STRING), expecting variable (T_VARIABLE) in /in/tmDYO on line 4
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_STRING in /in/tmDYO on line 3
Process exited with code 255.

preferences:
159.44 ms | 401 KiB | 210 Q