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'; public static $static = 'static'; public function privateMethod() { } } class B { private $private = 'private'; public $public = 'public'; } 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->getValue(); die(); //$p->setAccessible(true); //$p->setAccessible(false); try { $p->invoke(new A()); } catch (\ReflectionException $e) { var_dump($e->getCode()); } die(); $c = new B(); $p->setValue($c, 'b'); var_dump($p->getValue(new stdClass())); //$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/roZ25:49 Stack trace: #0 /in/roZ25(49): ReflectionProperty->getValue() #1 {main} thrown in /in/roZ25 on line 49
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:
40.49 ms | 401 KiB | 8 Q