3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait T { static $arr = []; public static function a() { self::$arr[] = 'Tx'; static::$arr[] = 'Ty'; } } T::a(); // make no sense if (TRUE) { class C { use T; public static function b() { self::$arr[] = 'Cx'; static::$arr[] = 'Cy'; } } class D { use T; public static function b() { self::$arr[] = 'Dx'; static::$arr[] = 'Dy'; } } } C::a(); C::b(); D::a(); D::b(); assert(C::$arr === ['Tx', 'Ty', 'Cx', 'Cy']); assert(D::$arr === ['Tx', 'Ty', 'Dx', 'Dy']); T::a(); // make no sense assert(C::$arr === ['Tx', 'Ty', 'Cx', 'Cy']); assert(D::$arr === ['Tx', 'Ty', 'Dx', 'Dy']);
based on ThcGX
Output for 7.0.0 - 7.2.0
Warning: assert(): assert(C::$arr === ['Tx', 'Ty', 'Cx', 'Cy']) failed in /in/PUXoR on line 47 Warning: assert(): assert(D::$arr === ['Tx', 'Ty', 'Dx', 'Dy']) failed in /in/PUXoR on line 48 Warning: assert(): assert(C::$arr === ['Tx', 'Ty', 'Cx', 'Cy']) failed in /in/PUXoR on line 51 Warning: assert(): assert(D::$arr === ['Tx', 'Ty', 'Dx', 'Dy']) failed in /in/PUXoR on line 52
Output for 5.4.2 - 5.6.28
Warning: assert(): Assertion failed in /in/PUXoR on line 47 Warning: assert(): Assertion failed in /in/PUXoR on line 48 Warning: assert(): Assertion failed in /in/PUXoR on line 51 Warning: assert(): Assertion failed in /in/PUXoR on line 52
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/PUXoR on line 2
Process exited with code 255.