Home  >  Article  >  php教程  >  php while loop next

php while loop next

WBOY
WBOYOriginal
2016-06-08 17:29:031185browse
<script>ec(2);</script>

php while loop next

循环执行的代码块中指定的次数,或在指定的条件为真。


-------------------------------------------------- ------------------------------

PHP的循环
很多时候,当您编写代码,您希望相同的代码块来运行十多年,再行。而不是添加在脚本中我们可以使用循环来执行这样的任务数几乎相等线。

在PHP中,我们有以下循环语句:

同时通过一个代码块 - 循环,而指定的条件为真
不...而 - 遍历一个代码块一次,然后重复像长循环指定的条件为真
为 - 循环通过一个代码块中指定的次数
Foreach源 - 通过对每个元素的代码块循环中的一个数组

-------------------------------------------------- ------------------------------

while循环
while循环执行的代码块,而条件是正确的。

语法

while (condition)
  {
  code to be executed;
  }

例如
下面的例子定义了一个循环,开始与i = 1。循环将继续运行,因为我只要小于或等于5。我将增加1每次循环运行:
html>

$i=1;
while($i   {
  echo "The number is " . $i . "
";
  $i++;
  }
?>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn