LoginSignup
0
0

More than 3 years have passed since last update.

[PHP] NULLか、それ以外か

Last updated at Posted at 2021-04-12

概要

PHPでNULLかそれ以外かを判定するための方法をメモします。

方法

  • NULLの場合はNULLを返す
  • NULL以外の場合はそれ以外を返す
<?php
$hoge = null;

if(is_null($hoge)){
    echo 'NULL';
}else{
    echo 'それ以外';
}

変数が未定義の場合もNULLになります。

0
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
0
0