3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A1 { protected function a() { $i = 0; $s = ''; while (true) { $i++; if ($i > 10000) { break; } foreach ([['a' => 1], 2, ['a' => 2]] as $p) { if ($p == 2) { continue; } if ($i % 1000 == 999) { throw new \Exception('t'); } yield $p['a'] => 123; } } } public function b() { $sum = 0; try { foreach ($this->a() as $k => $v) { $sum += $k + $v; } echo 'Done: ', $sum; } catch (\Exception $e) { echo $e; } } } (new A1)->b();
based on Ev1e1
Output for 7.0.0 - 7.2.0
Exception: t in /in/hSHVf:20 Stack trace: #0 /in/hSHVf(33): A1->a() #1 /in/hSHVf(43): A1->b() #2 {main}
Output for 5.5.24 - 5.6.28
exception 'Exception' with message 't' in /in/hSHVf:20 Stack trace: #0 /in/hSHVf(33): A1::a() #1 /in/hSHVf(43): A1->b() #2 {main}
Output for 5.4.11 - 5.4.45
Parse error: syntax error, unexpected '$p' (T_VARIABLE) in /in/hSHVf on line 24
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/hSHVf on line 15
Process exited with code 255.