关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。
想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。
8年前关闭。
Improve this question
你如何编写While 循环的语法?
C #
int i = 0;
while (i != 10)
{
Console.WriteLine(i);
i++;
}
VB.Net
Dim i As Integer = 0
While i <> 10
Console.WriteLine(i)
i += 1
End While
PHP
<?php
while(CONDITION)
{
//Do something here.
}
?>
<?php
//MySQL query stuff here
$result = mysql_query($sql, $link) or die("Opps");
while($row = mysql_fetch_assoc($result))
{
$_SESSION['fName'] = $row['fName'];
$_SESSION['lName'] = $row['lName'];
//...
}
?>
Python
i = 0
while i != 10:
print i
i += 1
最佳答案
在 PHP 中,while 循环将如下所示:
<?php
while(CONDITION)
{
//Do something here.
}
?>
一个真实世界的例子可能看起来像这样
<?php
//MySQL query stuff here
$result = mysql_query($sql, $link) or die("Opps");
while($row = mysql_fetch_assoc($result))
{
$_SESSION['fName'] = $row['fName'];
$_SESSION['lName'] = $row['lName'];
//...
}
?>
关于language-agnostic - 如何编写While循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42395/