3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Cache{ protected function put($key,$value){ static $cache = []; var_dump($cache); return $cache[$key] = $value; } } $instance1 = new class extends Cache{ public function store($key,$value) { return $this->put($key,$value); } }; $instance1->store("one",1); $instance1->store("two",2); $instance1->store("three",3); $instance2 = new class extends Cache{ public function store($key,$value) { return $this->put($key,$value); } }; $instance2->store("four",4); $instance2->store("five",5); $instance3 = new class extends Cache{ public function store($key,$value) { return $this->put($key,$value); } }; $instance3->store("six",6); $instance3->store("seven",7);

preferences:
32.67 ms | 402 KiB | 5 Q