I saw a code in the php Tutorial: while ($ rowmysql_fetcharray ($ result) {echo $ row [& #039; FirstName & #039;]. & quot ;. $ row [& #039; LastName & #039;]; echo & quot; & amp; lt; br & amp; gt; & quot ;}excuse me & quot; while () & quot; in addition to the function of executing a loop when the value in parentheses is true, what is the purpose... I saw a code in the php Tutorial:
While ($ row = mysql_fetcharray ($ result ))
{Echo $ row ['firstname']. "". $ row ['lastname'];
Echo"
";
}
What is the purpose of "while ()" In addition to the function of executing a loop when the value in the brackets is true? For example, the variables in the preceding Code brackets are neither TRUE nor FALSE.
(For Beginners, you may be an idiot. Please be patient. Thank you)
Reply content:
I saw a code in the php Tutorial:
While ($ row = mysql_fetcharray ($ result ))
{Echo $ row ['firstname']. "". $ row ['lastname'];
Echo"
";
}
What is the purpose of "while ()" In addition to the function of executing a loop when the value in the brackets is true? For example, the variables in the preceding Code brackets are neither TRUE nor FALSE.
(For Beginners, you may be an idiot. Please be patient. Thank you)
Here is not strictly determined, that is, 0, null, array (), false are considered to be false, the same 1, true, 'A', array ('A ') true.
While is a true loop, false is not a loop
However, all values other than 0 are true and 0 is false.
(A = B) returns the value of a, that is, the value of B, after the value is assigned.
Therefore, it can be regarded as true or false.
The prerequisite for determining whether the while clause ends iswhile($row=mysql_fetcharray($result))Internal$row=mysql_fetcharray($result)If it is true, it is always executed. If it is false, the loop is exited.
Another case is that if the while structure contains exit or break, it exits directly.