Php learning implementation code of the loop structure

Source: Internet
Author: User
Php learning loop structure implementation code. For more information, see. The code is as follows:


/* Loop structure
* 1. while loop
* While (expression)
*{
* Loop body; // execute repeatedly until the expression is false.
*}
* 2. do-while loop
* 3. for loop
*
* There are two types of loops based on different cyclic conditions.
*
* One Type: counting loop ()
* Another Type: conditional loop (usually while do-while)
*
*
*
*/
// While usage
/* $ Num = 0;
While ($ num <100)
{
Echo "output result {$ num }";
$ Num ++;
}*/
// While output table
Echo'


























';Echo' ';$ I = 0;While ($ I <1000){// Change a row every 10 timesIf ($ I % 10 = 0){If ($ I % 20 = 0){$ Bg = "# ffffff ";}Else{$ Bg = "# cccccc ";}Echo' '; // The color of the output line}Echo' ';$ I ++;If ($ I % 10 = 0){Echo' ';}}Echo'
Use the while output table
'. $ I .'
';
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.