LoginSignup
1
0

More than 3 years have passed since last update.

PHP 変数が空かどうか判定する

Last updated at Posted at 2021-01-17

目的

  • PHPで変数が空かどうか判定する方法をメモ的にまとめる

情報

方法

  • empty()関数を用いて変数が空かどうかを判定する。empty()関数は空の場合trueを返す。
  • 下記を実行すると変数$strは空のため「Empty data」の文字列が出力される。

    <?php
    
    $str = '';
    
    if (empty($str)) {
        echo 'Empty data';
    }
    

参考文献

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