PHP的for循环

Posted blog_zss小帅的博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP的for循环相关的知识,希望对你有一定的参考价值。

For循环执行代码块指定的次数,或者当指定的条件为真时循环执行代码块.for循环用于您预先知道脚本需要运行的次数的情况

for(初始值;条件;增量)

要执行的代码;

<html>
<body>
<?php
for ($i=1; $i<=5; $i++)

 {

  echo "The number is " . $i . "<br>";

 }
?>
</body>
</html>
输出:

The number is 1
The number is 2
The number is 3
The number is 4
The number is 5

 

以上是关于PHP的for循环的主要内容,如果未能解决你的问题,请参考以下文章