Home > php教程 > php手册 > php do while循环实例,phpdowhile实例

php do while循环实例,phpdowhile实例

WBOY
Release: 2016-06-13 08:38:46
Original
1780 people have browsed it

php do while循环实例,phpdowhile实例

do-while循环和while循环非常相似,其区别只是在于do-while保证必须执行一次,而while在表达式不成立时则可能不做任何操作。

do-while 循环只有一种语法:

do {
   statement
}while (expr)
Copy after login

例子:

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

该例子也是输出1到10。

原文地址:http://www.manongjc.com/php/php_while.html

php相关阅读:

php strlen() 获取字符串的长度

php strnatcasecmp() 比较两个字符串(对大小写不敏感)

php strnatcmp() 使用自然算法来比较两个字符串

php strpbrk() 在字符串中查找指定字符中的任意一个

php strrchr() 查找字符串在另一个字符串中最后一次出现的位置

php strrev() 反转字符串,将字符串颠倒

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template