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->getMethod('privateMethod'); $p->setAccessible(true); $p->setAccessible(false); var_dump($p->invoke(new stdClass())); $p = $r->getProperty('public'); $p->setAccessible(false); var_dump($p->getValue());
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught ReflectionException: Given object is not an instance of the class this method was declared in in /in/EIQlT:49 Stack trace: #0 /in/EIQlT(49): ReflectionMethod->invoke(Object(stdClass)) #1 {main} thrown in /in/EIQlT 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:
41.63 ms | 401 KiB | 8 Q