为什么 count(false) 返回 1? [英] Why count(false) return 1?

查看:36
本文介绍了为什么 count(false) 返回 1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你知道为什么 返回 1 吗?

Do you know why <?= count(false) ?> returns 1?

推荐答案

它的指定行为:

如果 var 不是数组或实现了 Countable 的对象接口,返回1.

If var is not an array or an object with implemented Countable interface, 1 will be returned.

根据http://php.net/manual/en/function.count.php

这篇关于为什么 count(false) 返回 1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆