3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php if (PHP_VERSION !== '7.1.6') die('Meh'); function kv(& $a) { $b = $a; end($b); $kv = [$k = key($b), current($b)]; // unset($b); // TRICKY: We must unset $b before modifying $a to avoid copy-on-write for $a. unset($a[$k]); return $kv; } $a = range(1, 2000000); next($a); next($a); echo current($a) . PHP_EOL; var_dump($a); var_dump(kv($a)); echo current($a) . PHP_EOL; var_dump($a);
based on NYk36
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.1.5, 7.1.7 - 7.3.0alpha1
Meh
Output for 7.1.6
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 67108872 bytes) in /in/Nhfaf on line 13
Process exited with code 255.