回答編集履歴

1

等価の式を分かりやすく対比で記載

2016/12/13 12:33

投稿

MEBITUS
MEBITUS

スコア83

test CHANGED
@@ -20,32 +20,34 @@
20
20
 
21
21
  if の中身が実行されます。
22
22
 
23
+  
23
24
 
25
+  
24
26
 
25
- 余談ですが、
27
+  
26
28
 
27
- isset と is_null は正反対の結果を返しはしますが、
28
-
29
- 同じ挙動をします。
29
+ 余談ですが、下記が同じ挙動をします。
30
30
 
31
31
 
32
32
 
33
+ (1)
34
+
33
35
  ```PHP
34
36
 
35
- $x = 0; // isset($x) === true is_null($x) === false
37
+ if ($foo)
36
38
 
37
- $x = 1; // isset($x) === true is_null($x) === false
38
-
39
- $x = ""; // isset($x) === true is_null($x) === false
40
-
41
- $x = null; // isset($x) === false is_null($x) === true
42
-
43
- $x = true; // isset($x) === true is_null($x) === false
44
-
45
- $x = false; // isset($x) === true is_null($x) === false
39
+ if (!empty($foo))
46
-
47
- $x = []; // isset($x) === true is_null($x) === false
48
-
49
- // 未定義 $x isset($x) === false is_null($x) === true
50
40
 
51
41
  ```
42
+
43
+
44
+
45
+ (2)
46
+
47
+ ```PHP
48
+
49
+ if (isset($foo))
50
+
51
+ if (!is_null($foo))
52
+
53
+ ```