3v4l.org

run code in 300+ PHP versions simultaneously
<?php class PHPFI { public $a = 'A PROPERTY'; protected $b = 'B PROPERTY'; private $c = 'C PROPERTY'; public function __construct() { unset($this->a, $this->b, $this->c); } } $phpfi = new PHPFI(); var_dump((array) $phpfi); // array(3) { // ["a"]=> // string(10) "A PROPERTY" // ["*b"]=> // string(10) "B PROPERTY" // ["PHPFIc"]=> // string(10) "C PROPERTY" // } $reflect = new ReflectionClass($phpfi); $reflectProps = $reflect->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED | ReflectionProperty::IS_PRIVATE); $props = []; foreach ($reflectProps as $prop) { switch (true) { case $prop->isProtected(): $prefix = '*'; break; case $prop->isPrivate(): $prefix = $prop->getDeclaringClass()->getName(); break; default: $prefix = ''; break; } $prop->setAccessible(true); $props[$prefix . $prop->getName()] = $prop->getValue($phpfi); } var_dump($props); // array(3) { // ["a"]=> // string(10) "A PROPERTY" // ["*b"]=> // string(10) "B PROPERTY" // ["PHPFIc"]=> // string(10) "C PROPERTY" // }
Output for git.master, git.master_jit, rfc.property-hooks
array(0) { } Warning: Undefined property: PHPFI::$a in /in/BtDs5 on line 44 Warning: Undefined property: PHPFI::$b in /in/BtDs5 on line 44 Warning: Undefined property: PHPFI::$c in /in/BtDs5 on line 44 array(3) { ["a"]=> NULL ["*b"]=> NULL ["PHPFIc"]=> NULL }

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:
60.93 ms | 402 KiB | 8 Q