0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

emptyを使って、trueを返す値を確かめる実験

Last updated at Posted at 2013-06-23

PHPマニュアルに

empty — 変数が空であるかどうかを検査する
http://php.net/manual/ja/function.empty.php

と書いてある。


emptyを使って、trueを返す値は、

0
null
false
''
""
空配列

らしい。そこで、実験。

index.php
<?php
    $var = array();
    $test_data = [0, null, false, '', "",$var];
        
    for ($i = 0, $l = count($test_data); $i < $l; $i++) {
        if (empty($test_data[$i])) {
            echo 'true'.'<br/>';
        } else {
            echo 'false'.'<br />';
        }
    }

実行結果は、全部trueでございました。
引き続き実験をしていきたい。

参考URL
「emptyとissetの違い」 ほげほげ(仮)
http://starzero.hatenablog.com/entry/20101117/1290002811

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?