Methods and simple examples of while loop control in php

墨辰丷
Release: 2023-03-29 11:36:01
Original
1624 people have browsed it

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 
}
Copy after login

or

while (expr): 
  statement 
endwhile;
Copy after login

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++; 
} 
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!