PHP while loop next

Source: Internet
Author: User

PHP while loop next

The number of times specified in the block of code that is being executed, or if the specified condition is true.


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

PHP's Loops
Many times, when you write code, you want the same code block to run for more than 10 years, and then do it again. Instead of adding in the script we can use loops to perform almost equal lines of the number of tasks.

In PHP, we have the following loop statement:

At the same time through a code block-loop, and the specified condition is true
No... Instead-iterate through a code block once, and then repeat the condition specified as the long loop is true
is the number of times specified by the loop through a block of code
foreach source-an array in the loop of code blocks for each element

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

While loop
The while loop executes the block of code, and the condition is correct.

Grammar

while (condition)
{
codeto is executed;
}

For example
The following example defines a loop, which begins with i = 1. The loop will continue to run as long as I am less than or equal to 5. I'm going to add 1 each time the loop runs:
Html>
<body>

<?php
$i = 1;
while ($i <=5)
{
echo "The number is". $i. "<br/>";
$i + +;
}
?>

</body>
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5

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.