Home >Backend Development >PHP Tutorial >Detailed explanation of the specific usage syntax of PHP function sizeof()_PHP tutorial
Everyone has reviewed PHP function sizeof() syntax:
sizeof(arrayname);
Tips and instructions
Note: This function may return 0 if a variable is not set, but may also return 0 if a variable contains an empty array. The isset() function can be used to test whether a variable is set.
Let’s take a look at an example of the PHP function 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 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></SPAN><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></SPAN><LI class=""><SPAN> </SPAN><LI class=alt><SPAN>echo $result; </SPAN><LI class=""><SPAN></SPAN><SPAN class=tag><STRONG><FONT color=#006699>?></span></font></strong></span><span> </span> </li></ol>
The output result is :4
From the above example, we can see that the PHP function sizeof() is the same as the count method.