3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A1 { var $s; protected function a () { $i =0 ; while (true) { $i++; if ($i > 10000) { break; } foreach ([['a' => 1],2, ['a' => 2]] as $p) { if ($p == 2) { continue; } if ($i %100 == 0) { $this->s .= str_repeat('0123456789', 1000000); } yield $p['a'] => 123; } } } public function b(){ $sum = 0; foreach ( $this->a() as $k => $v ) { $sum += $k + $v; } echo 'Done: ', $sum; }} (new A1)->b();
based on 9NIiB
Output for 7.0.0 - 7.0.20, 7.1.5 - 7.1.7, 7.2.0
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 60000032 bytes) in /in/rpSIt on line 14
Process exited with code 255.
Output for 7.1.10

Process exited with code 137.
Output for 7.1.0
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 40000032 bytes) in /in/rpSIt on line 14
Process exited with code 255.
Output for 5.5.24 - 5.6.28
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 60000001 bytes) in /in/rpSIt on line 14
Process exited with code 255.
Output for 5.4.11 - 5.4.45
Parse error: syntax error, unexpected '$p' (T_VARIABLE) in /in/rpSIt on line 16
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/rpSIt on line 9
Process exited with code 255.