3v4l.org

run code in 300+ PHP versions simultaneously
<?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());

preferences:
56.18 ms | 406 KiB | 6 Q