3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A1 { protected function a () { $i =0 ; while (true) { $i++; if ($i > 10000) { break; } foreach ([['a' => 1],2, ['a' => 2]] as $p) { if ($p == 2) { continue; } yield $p['a'] => 123; } } } public function b(){ $sum = 0; foreach ( a() as $k => $v ) { $sum += $k + $v; } echo 'Done: ', $sum; } } (new A1)->b();
based on IfKjD
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined function a() in /in/Y6MHM:18 Stack trace: #0 /in/Y6MHM(24): A1->b() #1 {main} thrown in /in/Y6MHM on line 18
Process exited with code 255.
Output for 5.5.24 - 5.6.28
Fatal error: Call to undefined function a() in /in/Y6MHM on line 18
Process exited with code 255.
Output for 5.4.11 - 5.4.45
Parse error: syntax error, unexpected '$p' (T_VARIABLE) in /in/Y6MHM on line 12
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/Y6MHM on line 8
Process exited with code 255.