如何在while或for循环中求和变量静态值


how to sum variable static values in while or for loop?

这对while或for循环中的sum variable static values可能吗?我有代码,正在处理它,但它只sum variables一次?

例如,我想要这样

我需要将b values与每个结果相加?

这里是我的代码

<?php 
$a='10';
$b='20';
$i=0;
while($i <=10)
{
$c=$c=$a+$b;
$i++;
?>
<input type="text" value="<?php echo $c[$i] ?>" />
<?php }?>
<?php
  $a = '10';
  $b = '20';
  $c = '0';
  $i = 0;
  while ($i <= 10) {
     $c = (int)$a + (int)$b + (int)$c;
     //your html input element with the value of c
     echo '<input type="text" value="' . $c . '" />';
     $i++;
  }

$i = 0时,结果将是10 + 20 + 0 = 30,并且输入元素的值30

$i = 1时,结果将是10 + 20 + 30 = 60,并且输入元素的值60

$i = 2时,结果将是10 + 20 + 60 = 90,并且输入元素的值90

等等。。。

这里有一个简单的循环

$a = '10';
$b = '20';
$c = 0;
$t = 10;
while($t --) {
    printf("<input type='"text'" value='"%s'" />", $c += $a + $b);
}
<?php 
$a='10';
$b='20';
$c = 0;
$i=0;
while($i <=10)
{
$c=$c+$a+$b;
$sum=$c+$b;
$i++;
?>

$c设置为某个值,然后添加