search

Home  >  Q&A  >  body text

do..while..若执行一次后while条件满足 do{}里面需要怎么添加代码?

$num=2;
$sum=10;
do{
$sum=$sum+10;
//需要添加什么代码
     }while($num>0)
echo $sum;


phpcn_u224phpcn_u2242983 days ago1163

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-09-30 23:00:52

    do..while..If the while condition is satisfied after executing it once, how do I need to add code to do{}? -PHP Chinese website Q&A-do..while..If the while condition is satisfied after executing once, how do I need to add code to do{}? -PHP Chinese website Q&A

    Please watch and learn.

    reply
    0
  • 阿神

    阿神2016-12-19 17:36:17

    do里面是执行  while是条件 不管第一次while的条件有没有合适 都会先执行一次do    第一次$sum是20;应该num本身就大于0,所以会一直执行   如果只想执行一次的话 while($num<2)

    reply
    0
  • Cancelreply