3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Ex extends \ReflectionException { public $reflector; public function __construct($reflector, $message = '', \Exception $previous = null) { parent::__construct($message, 0, $previous); $this->reflector = $reflector; } } class A { private $private = 'private'; public $public = 'public'; private function privateMethod() { } } class B { //public $private = 'pr'; private $public = 'pu'; } class C extends \ReflectionClass { public function __construct($name) { try { parent::__construct($name); } catch (\Exception $e) { throw new Ex($this, $e->getMessage(), $e); } } } $r = new \ReflectionClass('A'); $p = $r->getProperty('private'); $p->setAccessible(true); //$p->setAccessible(false); $p->setValue(new stdClass(), 'b'); var_dump($p->getValue()); //$p = $r->getProperty('public'); //$p->setAccessible(false); //var_dump($p->getValue(true));
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: ReflectionProperty::getValue(): Argument #1 ($object) must be provided for instance properties in /in/33a23:50 Stack trace: #0 /in/33a23(50): ReflectionProperty->getValue() #1 {main} thrown in /in/33a23 on line 50
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:
59.09 ms | 401 KiB | 8 Q