May 2016
Intermediate to advanced
155 pages
2h 15m
English
© Mikael Olsson 2016
Mikael Olsson, PHP 7 Quick Scripting Reference, 10.1007/978-1-4842-1922-5_7
Mikael Olsson1
(1)Hammarland, Finland
There are four looping structures in PHP. These are used to execute a specific code block multiple times. Just as with the conditional if statement, the curly brackets for the loops can be left out if there is only one statement in the code block.
The while loop runs through the code block only if its condition is true. It continues looping for as long as the condition remains true. Note that the condition is only checked at the beginning of each iteration (loop).
$i = 0;while ($i < 10) { echo $i++; } // 0-9
The do-while loop works in the same way as the while loop, except that it ...
Read now
Unlock full access