3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $a; private $b; public function __construct() { echo 'DA'; } public function getA() {return $this->a;} public function getB() {return $this->b;} public function setA($a) {$this->a = $a;} public function setB($b) {$this->b = $b;} } $class = new ReflectionClass('Foo'); $instance = $class->newInstanceWithoutConstructor(); var_dump($instance); $reflect = new ReflectionObject($instance); $properties = $reflect->getProperties(); $i = 0; foreach ($properties as $property) { $property->setValue($i); $i++; } var_dump($instance);
Output for git.master, git.master_jit, rfc.property-hooks
object(Foo)#2 (2) { ["a":"Foo":private]=> NULL ["b":"Foo":private]=> NULL } Fatal error: Uncaught ArgumentCountError: ReflectionProperty::setValue() expects exactly 2 arguments, 1 given in /in/80XWD:32 Stack trace: #0 /in/80XWD(32): ReflectionProperty->setValue(0) #1 {main} thrown in /in/80XWD on line 32
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
44.93 ms | 401 KiB | 8 Q