Home >Backend Development >PHP Tutorial >php do while loop example, phpdowhile example_PHP tutorial

php do while loop example, phpdowhile example_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:51:211078browse

php do while loop instance, phpdowhile instance

do-while loop and while loop are very similar, the only difference is that do-while guarantees that it must be executed once, while while in the expression If it is not established, no operation may be performed.

The do-while loop has only one syntax:

do {
   statement
}while (expr)

Example:

<?php
$i = 1;
do {
   echo $i;
   $i++;
} while ($i <= 10);
?>

This example also outputs 1 to 10.

Original address: http://www.manongjc.com/php/php_while.html

php related reading:

php strlen() gets the length of the string

php strnatcasecmp() compares two strings (not case sensitive)

php strnatcmp() uses natural algorithm to compare two strings

php strpbrk() finds any one of the specified characters in the string

php strrchr() finds the last occurrence of a string in another string

php strrev() reverses the string and reverses the string

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1130669.htmlTechArticlephp do while loop example, phpdowhile example do-while loop and while loop are very similar, the only difference is that do- while is guaranteed to be executed once, while while may be executed when the expression does not hold...
Statement:
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