3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $parents = [1 => 0, 2 => 1, 3 => 2]; $cache = [1 => 5, 2 => 4, 3 => 3]; function count_posts($category_id, $parents, $cache) { $sum = 0; foreach ($parents as $child) { $sum += count_posts($child, $parents, $child); } $sum += $cache[$category_id]; return $sum; } count_posts(1, $parents, $cache);
based on aQKq8
Output for 7.0.0 - 7.3.0rc3
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 262144 bytes) in /in/QHqBH on line 8
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 64 bytes) in /in/QHqBH on line 8
Process exited with code 255.
Output for 5.5.24 - 5.5.35
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 72 bytes) in /in/QHqBH on line 8
Process exited with code 255.
Output for 5.4.12 - 5.4.45
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 130968 bytes) in /in/QHqBH on line 9
Process exited with code 255.
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/QHqBH on line 3
Process exited with code 255.