array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'arrayobject.count.php', 1 => 'ArrayObject::count', ), 'up' => array ( 0 => 'class.arrayobject.php', 1 => 'ArrayObject', ), 'prev' => array ( 0 => 'arrayobject.construct.php', 1 => 'ArrayObject::__construct', ), 'next' => array ( 0 => 'arrayobject.exchangearray.php', 1 => 'ArrayObject::exchangeArray', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/spl/arrayobject/count.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7, PHP 8)
ArrayObject::count — 统计 ArrayObject 内 public 属性的数量
此函数没有参数。
示例 #1 ArrayObject::count() 例子
<?php
class Example {
public $public = 'prop:public';
private $prv = 'prop:private';
protected $prt = 'prop:protected';
}
$arrayobj = new ArrayObject(new Example());
var_dump($arrayobj->count());
$arrayobj = new ArrayObject(array('first','second','third'));
var_dump($arrayobj->count());
?>
以上示例会输出:
int(1) int(3)