3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $test1 = 'hello'; protected $test2 = 'world'; protected $test3; public function toArray() { $this->test1 = null; $this->test3 = false; $array = get_object_vars($this); return array_filter($array); } } $a = new A(); print_r($a->toArray());

preferences:
31.42 ms | 402 KiB | 5 Q