<?php function getNumber() { echo 'im getting called!' . PHP_EOL; return rand(0,10); } // getNumber gets called on every loop for ($i = 0; $i <= getNumber(); $i++) { echo 'loop' . PHP_EOL; } echo PHP_EOL . '---' . PHP_EOL . PHP_EOL; // getNumber gets called only once for ($i = getNumber(); $i > 0 ; $i--) { echo 'loop' . PHP_EOL; }
You have javascript disabled. You will not be able to edit any code.