fibonacci.php

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Fibonacci Numbers</title>
    <meta charset="utf-8">
  </head>
  <body>
  <h1>Fibonacci Numbers Less than 100</h1>
  <p>
  <?php
/* Computes the famous Fibonacci sequence using a loop.
 * The recurrence is F_n+1 = F_n + F_n-1
 */
    $fib1 = 1;
    $fib2 = $fib1;
# Need to print the first number before loop starts
    print $fib1;
    while( $fib2 < 100 ) {
      print ", " . $fib2;
      $fib3 = $fib1 + $fib2; // compute next Fibonacci number
      $fib1 = $fib2;         // shift so $fib1, $fib2 are latest two
      $fib2 = $fib3;
    }
  ?>
  </p>
  </body>
</html>