你知道为什么退货吗?<?= count(false) ?>1
<?= count(false) ?>
1
它指定的行为:
如果 var 不是数组或具有已实现可数接口的对象,则返回 1。
据 http://php.net/manual/en/function.count.php
因为也是一个值,如果 count() 不获取数组,而是一个有效变量,它将返回 .falsetrue1
false
true
$result = count(null); // $result == 0 $result = count(false); // $result == 1