3v4l.org

run code in 300+ PHP versions simultaneously
<?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 % 100 == 0) { echo $i, memory_get_usage(), PHP_EOL; try { $s .= str_repeat('0123456789', 100000); } catch (\Exception $e) { throw $e; } } 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();
Output for 7.4.0
100391608 1001395128 2002394552 2003394000 3004393424 3005392848 4006392272 4007391696 5008395216 5009394640 60010394064 60011393488 70012392912 70013392336 80014391760 80015395280 90016394704 90017394128 100018393552 100019392976 110020392400 110021391824 120022395344 120023394768 130024394192 130025393616 140026393040 140027392464 150028391888 150029395408 160030394832 160031394256 170032393680 170033393104 180034392528 180035391952 190036395472 190037394896 200038394320 200039393744 210040393168 210041392592 220042392016 220043395536 230044394960 230045394384 240046393808 240047393232 250048392656 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 49000032 bytes) in /in/Ev1e1 on line 22
Process exited with code 255.
Output for 7.3.0 - 7.3.12
100391632 1001395152 2002394576 2003394024 3004393448 3005392872 4006392296 4007391720 5008395240 5009394664 60010394088 60011393512 70012392936 70013392360 80014391784 80015395304 90016394728 90017394152 100018393576 100019393000 110020392424 110021391848 120022395368 120023394792 130024394216 130025393640 140026393064 140027392488 150028391912 150029395432 160030394856 160031394280 170032393704 170033393128 180034392552 180035391976 190036395496 190037394920 200038394344 200039393768 210040393192 210041392616 220042392040 220043395560 230044394984 230045394408 240046393832 240047393256 250048392680 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 49000032 bytes) in /in/Ev1e1 on line 22
Process exited with code 255.
Output for 7.2.17 - 7.2.25
100387944 1001391464 2002390888 2003390336 3004389760 3005389184 4006388608 4007388032 5008391552 5009390976 60010390400 60011389824 70012389248 70013388672 80014388096 80015391616 90016391040 90017390464 100018389888 100019389312 110020388736 110021388160 120022391680 120023391104 130024390528 130025389952 140026389376 140027388800 150028388224 150029391744 160030391168 160031390592 170032390016 170033389440 180034388864 180035388288 190036391808 190037391232 200038390656 200039390080 210040389504 210041388928 220042388352 220043391872 230044391296 230045390720 240046390144 240047389568 250048388992 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 49000032 bytes) in /in/Ev1e1 on line 22
Process exited with code 255.
Output for 7.2.0
100387984 1001391504 2002390928 2003390376 3004389800 3005389224 4006388648 4007388072 5008391592 5009391016 60010390440 60011389864 70012389288 70013388712 80014388136 80015391656 90016391080 90017390504 100018389928 100019389352 110020388776 110021388200 120022391720 120023391144 130024390568 130025389992 140026389416 140027388840 150028388264 150029391784 160030391208 160031390632 170032390056 170033389480 180034388904 180035388328 190036391848 190037391272 200038390696 200039390120 210040389544 210041388968 220042388392 220043391912 230044391336 230045390760 240046390184 240047389608 250048389032 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 49000032 bytes) in /in/Ev1e1 on line 22
Process exited with code 255.
Output for 7.1.26 - 7.1.33
100351432 1001354952 2002354376 2003353824 3004353248 3005352672 4006352096 4007351520 5008355040 5009354464 60010353888 60011353312 70012352736 70013352160 80014351584 80015355104 90016354528 90017353952 100018353376 100019352800 110020352224 110021351648 120022355168 120023354592 130024354016 130025353440 140026352864 140027352288 150028351712 150029355232 160030354656 160031354080 170032353504 170033352928 180034352352 180035351776 190036355296 190037354720 200038354144 200039353568 210040352992 210041352416 220042351840 220043355360 230044354784 230045354208 240046353632 240047353056 250048352480 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 49000032 bytes) in /in/Ev1e1 on line 22
Process exited with code 255.
Output for 7.1.0, 7.1.7
100351504 1001355024 2002354448 2003353896 3004353320 3005352744 4006352168 4007351592 5008355112 5009354536 60010353960 60011353384 70012352808 70013352232 80014351656 80015355176 90016354600 90017354024 100018353448 100019352872 110020352296 110021351720 120022355240 120023354664 130024354088 130025353512 140026352936 140027352360 150028351784 150029355304 160030354728 160031354152 170032353576 170033353000 180034352424 180035351848 190036355368 190037354792 200038354216 200039353640 210040353064 210041352488 220042351912 220043355432 230044354856 230045354280 240046353704 240047353128 250048352552 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 49000032 bytes) in /in/Ev1e1 on line 22
Process exited with code 255.
Output for 7.1.5 - 7.1.6
100351920 1001355440 2002354864 2003354312 3004353736 3005353160 4006352584 4007352008 5008355528 5009354952 60010354376 60011353800 70012353224 70013352648 80014352072 80015355592 90016355016 90017354440 100018353864 100019353288 110020352712 110021352136 120022355656 120023355080 130024354504 130025353928 140026353352 140027352776 150028352200 150029355720 160030355144 160031354568 170032353992 170033353416 180034352840 180035352264 190036355784 190037355208 200038354632 200039354056 210040353480 210041352904 220042352328 220043355848 230044355272 230045354696 240046354120 240047353544 250048352968 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 49000032 bytes) in /in/Ev1e1 on line 22
Process exited with code 255.
Output for 7.0.0 - 7.0.20
100355232 1001358752 2002358176 2003357624 3004357048 3005356472 4006355896 4007355320 5008358840 5009358264 60010357688 60011357112 70012356536 70013355960 80014355384 80015358904 90016358328 90017357752 100018357176 100019356600 110020356024 110021355448 120022358968 120023358392 130024357816 130025357240 140026356664 140027356088 150028355512 150029359032 160030358456 160031357880 170032357304 170033356728 180034356152 180035355576 190036359096 190037358520 200038357944 200039357368 210040356792 210041356216 220042355640 220043359160 230044358584 230045358008 240046357432 240047356856 250048356280 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 49000032 bytes) in /in/Ev1e1 on line 22
Process exited with code 255.
Output for 5.6.8 - 5.6.28
100227168 1001227144 2002227192 2003227144 3004227192 3005227144 4006227192 4007227144 5008227192 5009227144 60010227192 60011227144 70012227192 70013227144 80014227192 80015227144 90016227192 90017227144 100018227192 100019227144 110020227192 110021227144 120022227192 120023227144 130024227192 130025227144 140026227192 140027227144 150028227192 150029227144 160030227192 160031227144 170032227192 170033227144 180034227192 180035227144 190036227192 190037227144 200038227192 200039227144 210040227192 210041227144 220042227192 220043227144 230044227192 230045227144 240046227192 240047227144 250048227192 250049227144 260050227192 260051227144 270052227192 270053227144 280054227192 280055227144 290056227192 290057227144 300058227192 300059227144 310060227192 310061227144 320062227192 320063227144 330064227192 330065227144 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 66000001 bytes) in /in/Ev1e1 on line 22
Process exited with code 255.
Output for 5.5.24 - 5.5.35
100227128 1001227104 2002227152 2003227104 3004227152 3005227104 4006227152 4007227104 5008227152 5009227104 60010227152 60011227104 70012227152 70013227104 80014227152 80015227104 90016227152 90017227104 100018227152 100019227104 110020227152 110021227104 120022227152 120023227104 130024227152 130025227104 140026227152 140027227104 150028227152 150029227104 160030227152 160031227104 170032227152 170033227104 180034227152 180035227104 190036227152 190037227104 200038227152 200039227104 210040227152 210041227104 220042227152 220043227104 230044227152 230045227104 240046227152 240047227104 250048227152 250049227104 260050227152 260051227104 270052227152 270053227104 280054227152 280055227104 290056227152 290057227104 300058227152 300059227104 310060227152 310061227104 320062227152 320063227104 330064227152 330065227104 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 66000001 bytes) in /in/Ev1e1 on line 22
Process exited with code 255.

preferences:
93.47 ms | 402 KiB | 76 Q