<?php
$start1 = memory_get_usage();
echo $start1.' bytes'.PHP_EOL;
$rangeNum = range(1, 100);
foreach ($rangeNum as $num) {
echo $num . PHP_EOL;
}
$end = memory_get_usage();
echo $end - $start1 .' bytes'.PHP_EOL;
function my_range($start, $limit) {
for ($i=$start; $i<=$limit; $i++) {
yield $i;
}
}
$start2 = memory_get_usage();
echo $start2.' bytes'.PHP_EOL;
$rangeNum2 = my_range(1, 100);
foreach ($rangeNum2 as $num) {
echo $num . PHP_EOL;
}
$end = memory_get_usage();
echo $end - $start2 .' bytes'.PHP_EOL;