3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Base { public static $prop; } class Child extends Base { } // both values are A $expected = 'A'; Base::$prop = $expected; echo "Should be $expected and is " . Base::$prop . "\n"; echo "Should be $expected and is " . Child::$prop . "\n"; echo "\n"; // VALUES DIFFER $expected = 'B'; $property = new ReflectionProperty('Base', 'prop'); $property->setValue($expected); echo "Should be $expected and is " . Base::$prop . "\n"; echo "Should be $expected and is " . Child::$prop . "\n"; echo "\n"; // VALUES STILL DIFFER $expected = 'C'; Base::$prop = $expected; echo "Should be $expected and is " . Base::$prop . "\n"; echo "Should be $expected and is " . Child::$prop . "\n"; echo "\n";
based on erB4r
Output for 5.4.0 - 5.6.28, 7.0.1 - 7.2.0
Should be A and is A Should be A and is A Should be B and is B Should be B and is B Should be C and is C Should be C and is C
Output for 7.0.0
Should be A and is A Should be A and is A Should be B and is B Should be B and is A Should be C and is C Should be C and is A