Home >Backend Development >PHP Tutorial >PHP learning loop structure implementation code_PHP tutorial

PHP learning loop structure implementation code_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:28:45788browse

Copy code The code is as follows:

/* Loop structure
* 1. while loop
* while(expression)
* {
* loop body;//repeatedly execute until the expression is false
* }
* 2. do-while loop
* 3. for loop
*
* According to different loop conditions, there are two types of loops
*
* One: counting loop (generally use for)
* The other: conditional loop (Generally use while do-while)
*
*
*
*/
//Usage of while
/*$num=0;
while($num< ;100)
{
echo "Output result{$num}";
$num++;
}*/
//while output table
echo '';
echo '';
$ i=0;
while($i<1000)
{
//Change a line every 10 times
if($i%10==0)
{
if( $i%20==0)
{
$bg="#ffffff";
}
else
{
$bg="#cccccc";
}
echo '';//Output interlaced color change
}
echo '';
$i++;
if($i%10==0)
{
echo '}
}
echo '

Use while to output the table

'.$i.'
';
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323565.htmlTechArticleCopy the code as follows: ?php /* Loop structure* 1. while loop* while (expression) * { * Loop body;//Execute repeatedly until the expression is false* } * 2. do-while loop* 3. for loop...
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