freeCodeCamp/guide/english/php/while/index.md

21 lines
488 B
Markdown
Raw Normal View History

2018-10-12 19:37:13 +00:00
---
title: While Loop
---
## While Loops
A `while` loop executes statements within the loop as long as the loops condition is met.
### Syntax:
```php
2018-10-21 16:20:09 +00:00
<?php
2018-10-12 19:37:13 +00:00
$x = 0;
while ($x < 11) {
statement1;
$x++;
}
```
**Note:** The block code must have a statement that changes or increments the condition. Otherwise an infinite loop could result.
### More Information:
<a href='http://php.net/manual/en/control-structures.while.php' target='_blank' rel='nofollow'>PHP While Loop</a>