English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP String String Function Manual
The strcmp() function is used to compare two strings (case-sensitive).
strcmp(string1,string2)
Used to compare two strings (case-sensitive)
If str1 Less than str2 Returns < 0; if str1 Greater than str2 Returns > 0; if both are equal, returns 0.
Serial Number | Parameters and Description |
---|---|
1 | string1 It specifies the first string to be compared |
2 | string2 It specifies the second string to be compared |
Try the following example, compare two strings, if this function returns 0, then the two strings are equal.
<?php echo "If this function returns 0, then the two strings are equal."; echo "<br> The result is: "; echo strcmp("Hello world!","Hello world!"); ?>Test and see‹/›
Output Result
If this function returns 0, then the two strings are equal. The result is: 0