Created
August 6, 2016 15:26
-
-
Save Restoration/e5dd526da6dca303f6ed20c6e2abdfa4 to your computer and use it in GitHub Desktop.
is_null
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE> | |
| <html lang="ja"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| </head> | |
| <body> | |
| <?php | |
| /* | |
| nullとは | |
| ある変数が値をもたないことを表す | |
| 特別な値をさす | |
| 変数の値がnullかどうかを調べる場合は | |
| is_null関数を使って中身を調べる | |
| */ | |
| $a = null; | |
| $b = ''; | |
| //どちらも何も表示されない | |
| echo $a. '<br >'; | |
| echo $b. '<br>'; | |
| if($a == $b){ | |
| echo '$a と$bは等しい(==)<br>'; | |
| } else { | |
| echo '$aと$bは異なる(==)<br>'; | |
| } | |
| if($a === $b){ | |
| echo '$a と$bは等しい(===)<br>'; | |
| } else { | |
| echo '$aと$bは異なる(===)<br>'; | |
| } | |
| if(is_null($a)){ | |
| echo '$aはnullです<br>'; | |
| } else { | |
| echo '$aはnullではありません<br>'; | |
| } | |
| if(isset($a)){ | |
| echo '$aは定義されています'; | |
| } else { | |
| echo '$aは定義されていません<br>'; | |
| } | |
| ?> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment