3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $bar = 1; public $baz = 2; public $qux = 3; } $a = []; for ($i = 0; $i < 1000; $i++) { $a[] = new Foo(); } var_dump(memory_get_usage()); foreach ($a as $o) { foreach ($o as $p) {} } var_dump(memory_get_usage());
Output for 8.1.0 - 8.1.13
int(521632) int(897664)
Output for 8.0.0 - 8.0.26
int(521040) int(897072)
Output for 7.4.0 - 7.4.33
int(521344) int(897376)
Output for 7.3.0 - 7.3.33
int(521304) int(897336)

preferences:
51.66 ms | 409 KiB | 5 Q