PHP Classes

File: fwphp/glomodul/z_examples/OOP/fizzbuzz.php

Recommend this page to a friend!
  Classes of Slavko Srakocic   B12 PHP FW   fwphp/glomodul/z_examples/OOP/fizzbuzz.php   Download  
File: fwphp/glomodul/z_examples/OOP/fizzbuzz.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change: Update of fwphp/glomodul/z_examples/OOP/fizzbuzz.php
Date: 1 year ago
Size: 619 bytes
 

Contents

Class file image Download
<?php

function fizzbuzz($start, $end)
{
 
// generator function returns an object that can be iterated over


   
for ($i = $start; $i <= $end; $i++) {
       
// Note that $i is preserved between yields.
       
yield $i;
    }

 
/* $current = $start;
  while ($current <= $end) {
    if ($current%3 == 0 && $current%5 == 0) {
      yield "fizzbuzz n%3,5==0";
    } else if ($current%3 == 0) {
      yield "fizz n%3==0";
    } else if ($current%5 == 0) {
      yield "buzz n%5==0";
    } else {
      yield $current;
    }
    $current++;
  } */
}

foreach(
fizzbuzz(1,20) as $number) {
  echo
$number.'<br />';
}
?>