PHP two methods to determine the length of the string is very useful, the string is very useful
PHP program in the length of the string to judge, you can use strlen.
Method One:
$str = ' aaaaaa '; if (strlen ($STR) > 6) {echo "string greater than 6";}
Method Two:
if (Isset ($str {6}) {}
The two methods above, the second is more efficient.
In PHP, all of the variables are saved with a structure-zval, strlen although the Len is directly obtained, but there is still a function call, and isset is the syntax structure of PHP, so faster! Therefore, the second method can be used when judging whether a string is greater than or less than the number of characters.
http://www.bkjia.com/PHPjc/1057471.html www.bkjia.com true http://www.bkjia.com/PHPjc/1057471.html techarticle PHP determines the length of the two methods of string is very useful, the string is useful in PHP program string length, you can use strlen. Method One: $str = ' aaaaaa '; if (strlen ($STR) 6) {e ...