3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public static $elements = []; public function getElements() { return self::$elements; } } // let's create an instance of A $a = new A; $a::$elements['first_key'] = 'defined'; A::$elements['direct_instance_key'] = 'defined_too'; var_dump($a->getElements(), A::$elements); $b = new A; var_dump($b->getElements());
Output for 7.1.25 - 7.1.30, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.30, 8.0.0 - 8.0.22, 8.1.0 - 8.1.9
array(2) { ["first_key"]=> string(7) "defined" ["direct_instance_key"]=> string(11) "defined_too" } array(2) { ["first_key"]=> string(7) "defined" ["direct_instance_key"]=> string(11) "defined_too" } array(2) { ["first_key"]=> string(7) "defined" ["direct_instance_key"]=> string(11) "defined_too" }

preferences:
58.3 ms | 410 KiB | 5 Q