3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { private $a; public $b = 1; public $c; private $d; static $e; public function test() { var_dump(get_object_vars($this)); // we pass $this in here, private is available } } $test = new foo; var_dump(get_object_vars($test)); // This doesn't get the private stuff $test->test(); // but this one does
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
array(2) { ["b"]=> int(1) ["c"]=> NULL } array(4) { ["a"]=> NULL ["b"]=> int(1) ["c"]=> NULL ["d"]=> NULL }

preferences:
118.63 ms | 1403 KiB | 4 Q