在第一个循环的 while 循环中显示一次文本 [英] Display text once within while loop on the first loop

查看:40
本文介绍了在第一个循环的 while 循环中显示一次文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?php

$i = 0;

while(conditionals...) {

if($i == 0)
  print "<p>Show this once</p>";

print "<p>display everytime</p>";
$i++;
}
?>

这是否仅在第一次且仅在该次显示显示一次",并且只要 while 循环通过就显示每次显示"?

Would this only show "Show this once" the first time and only that time, and show the "display everytime" as long as the while loop goes thru?

推荐答案

是的,确实如此.

你也可以将 if 和 increment 结合起来,这样你就不会忘记增加:

You can also combine the if and the increment, so you won't forget to increment:

if (!$i++) echo "Show once.";

这篇关于在第一个循环的 while 循环中显示一次文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆