3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Base { public static $prop = 'BASE'; } class Child extends Base { } $excepted = 'REFLECTED'; $property = new ReflectionProperty('Base', 'prop'); $property->setValue($excepted); $actual = Base::$prop; echo "Should be $excepted and is $actual\n"; $actual = Child::$prop; echo "Should be $excepted and is $actual\n"; Base::$prop = strrev(strrev(Base::$prop)); // force new zval Base::$prop = $excepted; $actual = Base::$prop; echo "Should be $excepted and is $actual\n"; $actual = Child::$prop; echo "Should be $excepted and is $actual\n";

preferences:
82.38 ms | 402 KiB | 5 Q