「php」whileとbreakを使用するサンプル

書式
while (条件式){
処理コード
}
サンプルコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$count = 0;
while (true){
if ($count === 5) {
break;
}
echo "$count";
$count ++;
}
$count = 0; while (true){ if ($count === 5) { break; } echo "$count"; $count ++; }
$count = 0;

while (true){
      if ($count === 5) {
            break;
      }
      echo "$count"; 
      $count ++;
}

結果
01234

PHP

Posted by arkgame