PHP length calculation Confusion in the analysis of the problem of easy to confuse the length calculation
The example in this paper is about the confusion of length calculation in PHP. Share to everyone for your reference, as follows:
are often confused by the character functions of arrays and strings in PHP, as summarized below:
strlen ($string) function : Calculates the length of a string;
sizeof ($string, $mode) function : It is the alias of the Count () function, and the count () function is as follows:
int count (mixed var [, int mode])
Returns the number of cells in Var, usually an array, with only one cell for any other type.
For an object, if SPL is installed, you can invoke count () by implementing the countable interface. The interface has only one method count (), and this method returns the return value of the count () function.
If Var is not an array type or an object that implements the countable interface, 1 is returned, with one exception, and if Var is NULL then the result is 0.
Note: The optional mode parameter is available from PHP 4.2.0.
If the optional mode parameter is set to Count_recursive (or 1), COUNT () counts recursively on the array. is especially useful for calculating all cells of a multidimensional array. The default value for mode is 0. Count () does not recognize infinite recursion.
In short, the string with strlen (), the array with sizeof ().
More readers interested in PHP related content can view this site topic: "PHP Operations Office Document Skills Summary (including word,excel,access,ppt)", "PHP array" operation Skills Daquan, "PHP Sorting algorithm Summary", " PHP common traversal algorithm and skills summary, "PHP Data structure and algorithm tutorial", "PHP Programming Algorithm Summary", "PHP Math Skills Summary", "PHP Regular Expression Usage summary", "PHP operation and operator Usage Summary", "PHP String Usage Summary" and "PHP Common database Operation Skills Summary"
I hope this article is helpful to you in PHP programming.
http://www.bkjia.com/PHPjc/1133065.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133065.html techarticle PHP in the calculation of the length of the problem is easy to confuse analysis, PHP length calculation confusion in this paper, the example of the length calculation in PHP is easy to confuse problems. Share to everyone for your reference, specific ...