3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A implements ArrayAccess { function offsetGet($a){ return new A; } function offsetExists($a){ echo "exists"; if($a === 10){ return true; }else{ return false; } } function offsetSet($a, $b){} function offsetUnset($a){} } $x = new A; var_dump($x[10][20] ?? 20);

preferences:
25.06 ms | 404 KiB | 5 Q