int strcmp( string $str1, string $str2)
|
Note that the comparison is case-sensitive.
Parameters
str1 the first string.
str2 a second string.
return value
Returns a negative number if the str1 is less than str2, returns a positive number if the str1 is greater than str2, and returns 0 if they are equal. (returns 0 when equal)
Example:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$var1="Hello";
$var2="Hello";
if(strcmp($var1,$var2)==0)
{echo'相等';
}
else {
echo'不相等';
}
?>
|
strcasecmp-binary Security comparison string (case insensitive)
?
1 |
int strcasecmp(string$str1,string$str2)
|
Str1
The first string.
str2
A second string.
return value: If STR1 is less than str2 returns < 0, if STR1 is greater than str2 returns > 0, if both are equal, 0 is returned.
Example: $var 1= "Hello";
$var 2= "Hello";
if (strcasecmp ($var 1, $var 2) ==0) {
Echo ' $var 1isequalto$var2inacase-insensitivestringcomparison ';
}
?>
The above describes the PHP string comparison, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.