3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class A { private $test1 = 'hello'; protected $test2 = 'world'; public function toArray() { //$this->test1 = null; $array = get_object_vars($this); return array_filter($array); } } $a = new A(); print_r($a->toArray());
Output for 5.2.15 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [test1] => hello [test2] => world )