使用while循环卡在无限循环中的Fizz Buzz脚本 - php [关闭]

I'm trying to write a Fizz Buzz script using a while loop to cycle through the numbers 1-100 and echo each one to the screen.

I'm using the modulus operator to find if a number is a multiple of:

  • 3 in which case it echos Fizz,
  • 5 in which case it echos Buzz,
  • or if its a multiple of both 3 and 5 it echos FizzBuzz

I've written the code below, tested all its parts and it seems to work, but when I run the script, it gets stuck in an infinite loop, echoing Fizz.

$i = 1;

while ($i <= 100) {

    if ((3 % $i) === 0) {
        echo 'Fizz';
        $i = $i++;
    } else if ((5 % $i) === 0) {    
        $i = $i++;
        echo 'Buzz';        
    } else if ( ((3 % $i) === 0) && ((5 % $i) === 0)){
        echo 'FizzBuzz';
    } else {
        echo $i++;
    }

}

Any idea were I went wrong?

$i = 1;

while ($i <= 100) {

    $r = '';

    if ($i % 3 === 0) {
        $r .= 'Fizz';
    }

    if ($i % 5 === 0) {    
        $r .= 'Buzz';        
    }

    if (!$r) {
        $r = $i;
    }

    echo "$r
";
    ++$i;
}

Online demo: http://ideone.com/WbXZEd