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', 10000); } 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){} } (new A1)->b();
based on rpSIt
Output for 7.0.0 - 7.0.2
Parse error: syntax error, unexpected 'catch' (T_CATCH), expecting function (T_FUNCTION) in /in/uVo8c on line 28
Process exited with code 255.
Output for 5.5.24 - 5.6.17
Fatal error: Cannot use try without catch or finally in /in/uVo8c on line 28
Process exited with code 255.
Output for 5.4.11 - 5.4.45
Parse error: syntax error, unexpected '$p' (T_VARIABLE) in /in/uVo8c on line 16
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/uVo8c on line 9
Process exited with code 255.