This article mainly introduces the while loop control method and simple examples in php. Interested friends can refer to it. I hope it will be helpful to everyone.
The while loop is the simplest loop in PHP. Its basic format is:
while (expr){ statement }
or
while (expr): statement endwhile;
This syntax indicates that as long as the expr expression is TRUE, the statement will be executed until expr is FALSE. The statement indicates the action or logic to be executed.
<?php $i = 1; while ($i <= 10) { echo $i; $i++; } ?>
This example loops out 1 to 10.
Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
The reasons and solutions for the discontinuity of ID settings in PHP after they are incremented
PHP implementation judgment Method for mobile devices
PHP strip_tags() Strips the HTML tags in the string
The above is the detailed content of Methods and simple examples of while loop control in php. For more information, please follow other related articles on the PHP Chinese website!