PHP中的strcmp()函数
该strcmp()函数用于比较两个字符串。
注意-此功能区分大小写。
语法
strcmp(str1, str2)
参数
str1-要比较的第一个字符串
str2-要比较的第二个字符串
返回
该strcmp()函数返回-
0-如果两个字符串相等
<0-如果string1小于string2
>0-如果string1大于string2
示例
以下是一个例子-
<?php
echo strcmp("windows","Windows");
?>输出结果
以下是输出-
32
示例
让我们看另一个例子-
<?php
echo strcmp("Windows OS","Windows Operating System");
?>输出结果
以下是输出-
-7424