strcmp() function is used to compare two strings.
Note - This function is case sensitive.
strcmp(str1, str2)
str1 - The first string to compare
< strong>str2 - The second string to compare
The strcmp() function returns -
0 - if the two strings are equal
<0 - if string1 is less than string2<0 - 如果 string1 小于 string2
>0 - If string1 is greater than string2
The following is an example-
Live demonstration
<?php echo strcmp("windows","Windows"); ?>
The following is the output -
32
Let’s see another example-
Live Demonstration
<?php echo strcmp("Windows OS","Windows Operating System"); ?>
Here is the output-
-7424
The above is the detailed content of strcmp() function in PHP. For more information, please follow other related articles on the PHP Chinese website!