3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait P1 { public $x; } trait P2 { use P1; public $y; } trait P3 { use P2; public $z; } class A { use P1; } class B { use P2; } class C { use P2; use P3; } $c = new C; $c->x = 42; $c->y = 37; $c->z = 23; var_dump($c);
Output for 7.0.0 - 7.2.0
object(C)#1 (3) { ["y"]=> int(37) ["x"]=> int(42) ["z"]=> int(23) }
Output for 5.4.11 - 5.6.28
Strict Standards: P2 and P3 define the same property ($y) in the composition of C. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in /in/4AlZT on line 23 Strict Standards: P2 and P3 define the same property ($x) in the composition of C. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in /in/4AlZT on line 23 object(C)#1 (3) { ["y"]=> int(37) ["x"]=> int(42) ["z"]=> int(23) }
Output for 5.4.2 - 5.4.10
Strict Standards: P2 and P3 define the same property ($y) in the composition of C. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in /in/4AlZT on line 23 Strict Standards: P2 and P3 define the same property ($x) in the composition of C. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in /in/4AlZT on line 23 object(C)#1 (3) { ["z"]=> int(23) ["y"]=> int(37) ["x"]=> int(42) }
Output for 5.3.17 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/4AlZT on line 2
Process exited with code 255.