3v4l.org

run code in 300+ PHP versions simultaneously
<?php class PhpClassWithPropertyDefaults { public $propertyWithoutDefault; public $propertyWithNullDefault = null; public $propertyWithTrueDefault = true; } $class = new ReflectionClass('PhpClassWithPropertyDefaults'); $defaults = $class->getDefaultProperties(); var_dump($defaults); var_dump($defaults[0]->name, $defaults[0]->getValue()); var_dump($defaults[1]->name, $defaults[1]->getValue()); var_dump($defaults[2]->name, $defaults[2]->getValue());

preferences:
46.22 ms | 402 KiB | 5 Q