LoginSignup
16
15

More than 5 years have passed since last update.

JavaScriptとPHPの論理値の比較

Last updated at Posted at 2015-03-18

下記の投稿で論理値の確認をしましたが、似たような項目を表にしておきます。
他の言語についてもご存知の方いらっしゃいましたら、後学の為にも編集リクエストもらえたらなんて都合のいいこと考えています :smirk:

調べた値 JavaScript PHP 備考
Boolean(true) true true
Boolean(false) false false
数値(0) false false
数値(1) true true
数値(NaN(非数値)) false true PHPはis_nan()と同値となる
数値(0==null) false true
文字列(0) true false
文字列(1) true true
空の文字列 false false
半角スペース true true
NULL false false
未定義の変数$a false false
未定義の変数$a == null true true
未定義の変数$a === null false true
未定義の変数$a === undefined true - PHPにundefinedはない
空の配列 true false
値を返さない関数 false false
0を返す関数 false false
1を返す関数 true true
関数オブジェクト true true
16
15
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
16
15