fork download
  1. <?php
  2.  
  3. function limited() {
  4. static $invocationcount = 0;
  5. ++$invocationcount;
  6.  
  7. if($invocationcount <= 3) {
  8. echo "You have called this function $invocationcount times.\n";
  9. }
  10. else {
  11. echo "Stop doing that!\n";
  12. }
  13. }
  14.  
  15. for($i = 0; $i < 5; ++$i) limited();
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
You have called this function 1 times.
You have called this function 2 times.
You have called this function 3 times.
Stop doing that!
Stop doing that!