Home > php教程 > php手册 > PHP函数sizeof()的具体使用语法详解

PHP函数sizeof()的具体使用语法详解

WBOY
Release: 2016-06-13 11:06:39
Original
1787 people have browsed it

大家通过对PHP函数sizeof()语法:

sizeof(arrayname);

提示和说明

注:此功能可能会返回0 ,如果一个变量没有设置,但也可能返回0 ,如果一个变量包含一个空数组。该isset ( )函数可以用来测试一个变量是否设置。

下面我们就来看看PHP函数sizeof()的实例吧。

<ol class="dp-xml">
<li class="alt"><span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">php</span></font></strong><span> </span></span></li>
<li class="">
<span>$</span><span class="attribute"><font color="#ff0000">people</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">array</font></span><span>("a", "Joe", "b", "C");  </span>
</li>
<li class="alt">
<span>$</span><span class="attribute"><font color="#ff0000">result</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">sizeof</font></span><span>($people);  </span>
</li>
<li class=""><span> </span></li>
<li class="alt"><span>echo $result;  </span></li>
<li class="">
<span></span><span class="tag"><strong><font color="#006699">?></font></strong></span><span> </span>
</li>
</ol>
Copy after login

输出结果为:4

从上例中我们可以看出,PHP函数sizeof()与count方法是一样的。


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template