<tfoot id='tnBWf'></tfoot>

  1. <legend id='tnBWf'><style id='tnBWf'><dir id='tnBWf'><q id='tnBWf'></q></dir></style></legend>
  2. <i id='tnBWf'><tr id='tnBWf'><dt id='tnBWf'><q id='tnBWf'><span id='tnBWf'><b id='tnBWf'><form id='tnBWf'><ins id='tnBWf'></ins><ul id='tnBWf'></ul><sub id='tnBWf'></sub></form><legend id='tnBWf'></legend><bdo id='tnBWf'><pre id='tnBWf'><center id='tnBWf'></center></pre></bdo></b><th id='tnBWf'></th></span></q></dt></tr></i><div id='tnBWf'><tfoot id='tnBWf'></tfoot><dl id='tnBWf'><fieldset id='tnBWf'></fieldset></dl></div>

    <small id='tnBWf'></small><noframes id='tnBWf'>

      • <bdo id='tnBWf'></bdo><ul id='tnBWf'></ul>
    1. while() 和 for() 有什么区别?

      时间:2023-09-20
    2. <legend id='IXUqC'><style id='IXUqC'><dir id='IXUqC'><q id='IXUqC'></q></dir></style></legend>
      <i id='IXUqC'><tr id='IXUqC'><dt id='IXUqC'><q id='IXUqC'><span id='IXUqC'><b id='IXUqC'><form id='IXUqC'><ins id='IXUqC'></ins><ul id='IXUqC'></ul><sub id='IXUqC'></sub></form><legend id='IXUqC'></legend><bdo id='IXUqC'><pre id='IXUqC'><center id='IXUqC'></center></pre></bdo></b><th id='IXUqC'></th></span></q></dt></tr></i><div id='IXUqC'><tfoot id='IXUqC'></tfoot><dl id='IXUqC'><fieldset id='IXUqC'></fieldset></dl></div>
        <bdo id='IXUqC'></bdo><ul id='IXUqC'></ul>

        <small id='IXUqC'></small><noframes id='IXUqC'>

          <tfoot id='IXUqC'></tfoot>

                  <tbody id='IXUqC'></tbody>
                本文介绍了while() 和 for() 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                也许我的问题看起来很初级,但实际上并非如此.我声称我可以通过 while() 使用 for() 完成一切,反之亦然.那么当有 for()while() 真的有用吗?我需要一个例子,我可以通过 for() 做到这一点,而我不能通过 while() 做到这一点.有?我认为没有......!

                Maybe my question seems primary, But actually it is not. I claim that I can do everything is done with for() by while(), And conversely. So really when while() is useful when there is for()? I need to a example that I can do that by for() and I can not do that by while(). There is? I think there is not ...!

                结构如下:

                for (init counter; test counter; increment counter) {
                    code to be executed;
                }
                
                
                init counter;
                while (test counter) {
                    code to be executed;
                    increment counter;
                }
                

                看到了吗?它们完全一样,现在我想知道为什么 php 两者都有?

                see? they are exactly the same, Now I want to know why php has both of them?

                推荐答案

                区别在于 do while 循环至少执行一次,因为它在退出时检查循环条件.while 是入口控制循环,而 do while 是出口控制循环.而在 do while 循环中,它将进入循环,然后检查条件.

                The difference is that the do while loop executes at least once because it checks for the loop condition while exiting. While is a entry controlled loop and do while is a exit control loop. Whereas in do while loop it will enter the loop and will then check for the condition.

                while 循环 - 用于循环直到满足条件并且不确定代码应该循环多少次

                while loop - used for looping until a condition is satisfied and when it is unsure how many times the code should be in loop

                for 循环 - 用于循环直到满足条件,但在您知道代码需要循环多少次时使用

                for loop - used for looping until a condition is satisfied but it is used when you know how many times the code needs to be in loop

                do while 循环 - 在检查 while 条件之前执行一次循环内容.

                do while loop - executes the content of the loop once before checking the condition of the while.

                这篇关于while() 和 for() 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:从while循环中获取计数器的更简单方法? 下一篇:运行while循环时的进度条

                相关文章

                最新文章

              • <legend id='oHa8M'><style id='oHa8M'><dir id='oHa8M'><q id='oHa8M'></q></dir></style></legend>

                1. <tfoot id='oHa8M'></tfoot>

                  <small id='oHa8M'></small><noframes id='oHa8M'>

                2. <i id='oHa8M'><tr id='oHa8M'><dt id='oHa8M'><q id='oHa8M'><span id='oHa8M'><b id='oHa8M'><form id='oHa8M'><ins id='oHa8M'></ins><ul id='oHa8M'></ul><sub id='oHa8M'></sub></form><legend id='oHa8M'></legend><bdo id='oHa8M'><pre id='oHa8M'><center id='oHa8M'></center></pre></bdo></b><th id='oHa8M'></th></span></q></dt></tr></i><div id='oHa8M'><tfoot id='oHa8M'></tfoot><dl id='oHa8M'><fieldset id='oHa8M'></fieldset></dl></div>

                      <bdo id='oHa8M'></bdo><ul id='oHa8M'></ul>