0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PHPのwhileでループ処理を行いましょう☆

Posted at

whileを使って条件が満たされている間、

繰返しができるループ処理をしていきましょう!

50点を持っていて、-10ずつ減らしていきます。

index.php
<?php

$score = 50;

while ($score > 0) {
   echo "あなたの点数は $score です!" . PHP_EOL;
   $score -= 10;
}

ターミナルに以下を入力します!

~$ php index.php

このように出力されます!

~ $ php index.php
あなたの点数は 50 です!  // -10ずつ減っていきます
あなたの点数は 40 です!
あなたの点数は 30 です!
あなたの点数は 20 です!
あなたの点数は 10 です!
~ $ 
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?