Advertisement
adnan360

loop-test.php

May 19th, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <html>
  2. <head>
  3.     <title>Loop test</title>
  4. </head>
  5. <body>
  6.  
  7.     Set the p GET variable for setting total loops<br/>
  8.     For example, run:<br/>
  9.     <code><?php
  10.     $n = rand(5 ,100);
  11.     echo( '<a href="'.$_SERVER['PHP_SELF'] . "?p=$n".'">' . $_SERVER['PHP_SELF'] . "?p=$n" . '</a>' ); ?></code> to get <?php echo $n; ?> iterations.<br/>
  12.     Default is 10.
  13.     <hr/>
  14.  
  15.     <?php
  16.         // get the user GET value
  17.         $p = (int) @$_GET['p'];
  18.         // is p is not set then loop 10 times
  19.         if ($p == '') { $p=10; }
  20.  
  21.         for ($i=1; $i <= $p; $i++) {
  22.             echo "Hello $i<br/>";
  23.         }
  24.  
  25.     ?>
  26.  
  27. </body>
  28. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement