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?

演算子一覧 🍵

Last updated at Posted at 2026-01-17

🔍 比較演算子(条件判定で使う)

記号 意味 説明
== 等しい(値のみ比較) 3 == "3" → true 型は無視して値だけ比較
=== 完全に等しい(値と型) 3 === "3" → false 値も型も同じなら true
!= 等しくない(値のみ比較) 3 != "4" → true 型は無視して比較
!== 完全に等しくない(値 or 型) 3 !== "3" → true 値または型が違えば true
> より大きい 5 > 3 → true
< より小さい 2 < 4 → true
>= 以上 5 >= 5 → true
<= 以下 4 <= 5 → true

➕ 算術演算子(計算で使う)

記号 意味 説明
+ 足し算 2 + 3 → 5
- 引き算 5 - 2 → 3
* 掛け算 4 * 2 → 8
/ 割り算 6 / 2 → 3
% 割った余り 7 % 3 → 1 偶数・奇数判定などに便利
** べき乗 2 ** 3 → 8 PHP7 以降、JS でも使用可能

♻️ 代入・複合代入演算子

記号 意味 説明
= 代入 $a = 5
+= 加算して代入 $a += 2 $a = $a + 2 と同じ
-= 減算して代入 $a -= 1
*= 掛けて代入 $a *= 3
/= 割って代入 $a /= 2
%= 余りで代入 $a %= 2

🔁 論理演算子(条件の組み合わせ)

記号 意味 説明
&& AND(かつ) a > 0 && a < 10 両方が true のとき true
|| OR(または) a < 0 || a > 100 どちらかが true なら true
! NOT(否定) !isAdmin 値を反転(true → false)

🔢 インクリメント・デクリメント

記号 意味 説明
++ 1 を加算 $a++ $a = $a + 1 と同じ
-- 1 を減算 $a-- $a = $a - 1 と同じ

✨ その他よく使う記号

記号 意味 説明
? : 三項演算子 $a ? $b : $c if 文の簡易版(条件 ? 真 : 偽)
?? null 合体演算子 $a = $b ?? 0 $b が null なら 0
=> 配列のキー指定 ["key" => "value"] PHP の連想配列で使用
-> オブジェクト参照 $obj->name オブジェクトのプロパティ参照
:: クラスの静的アクセス ClassName::method() 定数・static 関数へのアクセス

🧠 補足

  • 多くの言語で共通して使える(PHP, JavaScript, Java, C#, C++, Python など)
  • ===, !== は JavaScript や PHP では非常に重要(暗黙の型変換に注意)
0
0
1

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?