douyi8408 2017-04-01 06:22 采纳率: 0%
浏览 123
已采纳

有人可以为我解释一下 - 因为(i = 0; i = 10; i ++)

I know this below statement works

for ($i= 0; $i=<10; $i++)

will output till 0 to 10 but when I write this code

for ($i=0; $i=10; $i++)

it print 10 for unlimited times... why why it not print 0 to 10... what error I have done to get the result 0 to 10 for it....

  • 写回答

5条回答 默认 最新

  • dongyong5255 2017-04-01 06:25
    关注

    The middle term in a for loop is the condition that says whether the loop should continue running. i=10 assigns 10 to i, and it also evaluates to the number 10, which is not zero, so it's considered true. Since the loop's condition is always true, it never stops running.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类