3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TestingInjectingToProtected { protected $value; public function getValue(); } $object = new TestingInjectingToProtected(); $reflection = new ReflectionObject($object); $property = $reflection->getProperty('value'); $property->setAccessible(true); $object->value = 'foo'; $property->setAccessible(false); echo $object->getValue(); $injector = Closure::bindTo(function ($property, $value) { $this->$property = $value; }, $object); $injector('value', 'bar'); echo $object->getValue();
Output for 5.3.0 - 5.3.24, 5.4.0 - 5.4.15
Fatal error: Non-abstract method TestingInjectingToProtected::getValue() must contain body in lpmon on line 7
Process exited with code 255.
Output for 5.3.25
Fatal error: Non-abstract method TestingInjectingToProtected::getValue() must contain body in /in/Xj5Ln on line 7
Process exited with code 255.

preferences:
176.98 ms | 1395 KiB | 49 Q