LoginSignup
0
0

More than 3 years have passed since last update.

PHP基礎 -算術演算子をマスターする-

Last updated at Posted at 2021-01-09

PHPでは基本的な四則演算ができる算術演算子を使うことができます。

$i = 1 + 1;

$i = 1 - 1;

$i = 8 * 2;

$i = 8 / 2;

$i = 3 % 2;

効率的に開発を進めるため、再代入をする際に省略系で書くこともできます。

$i += 1;

$i -= 1;

$i *= 2;

$i /= 2;

さらに、+1と-1の再代入は繰り返し処理などで特に多用することのなるため、以下のように書くこともできます。

$i++;

$i--;
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