1
0
mirror of https://github.com/php/doc-zh.git synced 2026-03-28 00:52:06 +01:00
Files
archived-doc-zh/reference/array/functions/count.xml
Dallas Wang 9912944367 Translation completed.
git-svn-id: https://svn.php.net/repository/phpdoc/zh/trunk@95633 c90b9560-bf6c-de11-be94-00142212c4b1
2002-09-13 03:20:17 +00:00

86 lines
2.3 KiB
XML
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="gb2312"?>
<!-- $Revision: 1.1 $ -->
<!-- $Author: dallas $ -->
<!-- EN-Revision: 1.4 Maintainer: dallas Status: ready -->
<refentry id="function.count">
<refnamediv>
<refname>count</refname>
<refpurpose>统计变量中的单元数目</refpurpose>
</refnamediv>
<refsect1>
<title>说明</title>
<methodsynopsis>
<type>int</type><methodname>count</methodname>
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
</methodsynopsis>
<para>
返回 <parameter>var</parameter> 中的单元数目,通常是一个
<type>array</type>(任何其它类型都只有一个单元)。
</para>
<para>
如果 <parameter>var</parameter> 不是数组类型,将返回
<literal>1</literal>(例外:<literal>count(&null;)</literal> 的结果是 <literal>0</literal>)。
</para>
<warning>
<para>
<function>count</function> 对没有初始化的变量返回 0但对于空的数组也会返回 0。用
<function>isset</function> 来测试变量是否已经初始化。
</para>
</warning>
<para>
请参考手册中<link linkend="language.types.array">数组</link>一节中关于怎样在
PHP 中实现和使用数组的详细解释。
</para>
<para>
<example>
<title><function>count</function> 例子</title>
<programlisting role="php">
<!-- TODO: examples about count(null), count(false), count(object).. -->
<![CDATA[
$a[0] = 1;
$a[1] = 3;
$a[2] = 5;
$result = count ($a);
// $result == 3
$b[0] = 7;
$b[5] = 9;
$b[10] = 11;
$result = count ($b);
// $result == 3;
]]>
</programlisting>
</example>
</para>
<note>
<para>
<function>sizeof</function> 函数是 <function>count</function><link linkend="aliases">别名</link>
</para>
</note>
<para>
参见 <function>is_array</function><function>isset</function><function>strlen</function>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->