Do you know why <?= count(false) ?>
returns 1
?
It's specified behavior:
If var is not an array or an object with implemented Countable interface, 1 will be returned.
According to http://php.net/manual/en/function.count.php
Because false
is also a value and if the count() does not get array but a valid variable it returns true
which is 1
.
$result = count(null);
// $result == 0
$result = count(false);
// $result == 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With