int
strcmp
( string
$str1
, string
$str2
)
|
Note that this comparison
is case sensitive
writing.
parameter
str1
first string.
str2
second string.
return value
If
str1
is less than
str2
, returns negative; if
str1
is greater than
str2
, returns a positive number; both are equal Returns
0
. (Equal returns 0)
Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
<?php
$var1
=
"Hello"
;
$var2
=
"Hello"
;
if
(
strcmp
(
$var1
,
$var2
)==0)
{
echo
'相等'
;
}
else
{
echo
'不相等'
;
}
?>
|
strcasecmp
- Binary safe string comparison (not case sensitive)
1
|
int
strcasecmp
(string
$str1
,string
$str2
)
|
-
str1
-
The first string.
-
str2
-
The second string.
Return Value: returns if str1 is less than str2 <0; if str1 is greater than str2 returns> 0; if both are equal, it returns 0.
示例 :<?php
$var1="Hello";
$var2="hello";
if(strcasecmp($var1,$var2)==0){
echo'$var1isequalto$var2inacase-insensitivestringcomparison';
}
?>
$var1="Hello";
$var2="hello";
if(strcasecmp($var1,$var2)==0){
echo'$var1isequalto$var2inacase-insensitivestringcomparison';
}
?>