Let's Get Started with a PHP while Page!

  1. Open Notepad++
  2. Choose: File -> New
  3. Copy the PHP while Template (PHP) code (below)
  4. Paste that code into your new file
  5. Change the put-welcome-heading-here, and put-welcome-paragraph here strings.
  6. Change the put-title-of-this-page-here to:
    while
  7. Click: File -> Save As
  8. Name your file: /public_html/while.php
  9. Change the Save as type: to: PHP Hypertext Preprocessor (*.php)
  10. Click: Save
  11. Visit your page (http://bscacad3.buffalostate.edu/while.php) in your favorite web browser
  12. Make any changes
  13. Save your changes

PHP while Template (PHP)

<?php 
$title = "put-title-of-this-page-here"; 
$h2    = "put-heading-of-this-page-here"; 
$par   = "put-paragraph-of-this-page-here"; 
?>
<!doctype html>
<html>
  <head>
    <title><?php echo($title); ?></title>
  <head>
  <body>
    <h2><?php echo($h2); ?></h2>
    <p><?php echo($par); ?></p>
    <?php
    $myArray = array("item-0", "item-1", "item-2", "item-3", "item-4");
    $counter = 0;
    $maxNum = count($myArray);  
    /* Loop until $counter is greater than $maxNum */
    while ($counter < $maxNum) {
      echo("counter = $counter & myArray[$counter] = " . $myArray[$counter] . "<br/>\n");
      $counter++;
    }
    ?>   
  </body>
</html>
Output