Home  >  Article  >  Backend Development  >  php学习之 循环结构实现代码_PHP

php学习之 循环结构实现代码_PHP

WBOY
WBOYOriginal
2016-06-01 12:16:58737browse
复制代码 代码如下:
/* 循环结构
* 一、while循环
* while(表达式)
* {
* 循环体;//反复执行,直到表达式为假
* }
* 二、do-while循环
* 三、for循环
*
* 根据循环条件不同,有两种类型的循环
*
* 一种:计数循环 (一般使用for)
* 另一种:条件型循环 (一般使用 while do-while)
*
*
*
*/
//while的使用
/*$num=0;
while($num{
echo "输出结果{$num}";
$num++;
}*/
//while输出表格
echo '';
echo '';
$i=0;
while($i{
//隔10次换一行
if($i%10==0)
{
if($i%20==0)
{
$bg="#ffffff";
}
else
{
$bg="#cccccc";
}
echo '';//输出隔行换色
}
echo '';
$i++;
if($i%10==0)
{
echo '';
}
}
echo '

使用while输出表格

'.$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