php言語をおけるemptyとissetの違いについて
emptyは空かどうかを判定し、空ならtrueを返す。
逆にissetは入っているかを判定し、入っていればtrueを返す。
だから、下記のような認識をしていた。
sample.php
empty === !isset
しかし、これは間違っています。
それは、0の判定の場合です。
emptyは「0」は「空」と判定します。
一方issetは「0」は「入っている」と判定します。
また、issetは空の配列も「入っている」と判定します。
ここの部分がemptyとissetの違いです。
ですから、その時の状況によってemptyとissetを使い分けるようにしましょう。