LoginSignup
1
0

More than 3 years have passed since last update.

51歳からのプログラム 備忘録 empty isset if(変数) の戻り値

Posted at

isset,emptyなど、混乱するので、テストしてまとめてみた。
同じようなのがあれば、ここに追記していこう。

if(empty($param))

変数の存在 変数の値 戻り値
存在しない true
存在する 無い true
存在する 有る false

if(!empty($param))

変数の存在 変数の値 戻り値
存在しない false
存在する 無い false
存在する 有る true

if(isset($param))

変数の存在 変数の値 戻り値
存在しない false
存在する 無い false
存在する 有る true

if(!isset($param))

変数の存在 変数の値 戻り値
存在しない true
存在する 無い true
存在する 有る false

if($param)の戻り値

変数の存在 変数の値 戻り値
存在しない undefine variable
存在する 無い undefine variable
存在する 有る true

if(!$param)の戻り値

変数の存在 変数の値 戻り値
存在しない undefine variable
存在する 無い undefine variable
存在する 有る false
1
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
1
0