3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = []; readonly class T { public function __construct(public int $x, public int $y) {}} for($x = 0; $x <= 100_000; $x++) $arr[] = new T(1,2); echo "Current memory usage: " . (memory_get_usage() / 1024) . " KB\n"; echo "Peak memory usage: " . (memory_get_peak_usage() / 1024) . " KB\n";
Output for 8.4.1
Current memory usage: 11260.71875 KB Peak memory usage: 11264.71875 KB
Output for 8.2.0 - 8.2.28, 8.3.0 - 8.3.14
Current memory usage: 11260.6953125 KB Peak memory usage: 11264.6953125 KB
Output for 8.1.0 - 8.1.31
Parse error: syntax error, unexpected token "readonly", expecting end of file in /in/1vhNp on line 5
Process exited with code 255.

preferences:
78.06 ms | 408 KiB | 5 Q