The strcmp () function is used to compare two strings. if the two strings are completely equal, 0 is returned. otherwise, various return values are returned. This function is case-sensitive and can be used as a reference. the return value after comparison indicates that if str1 and str2 are equal, return... the strcmp () function is used to compare two strings. if the two strings are completely equal, 0 is returned. otherwise, various return values are returned. This function is case-sensitive and can be used as a reference.
Return value after Comparison
If str1 and str2 are equal, 0 is returned.
If str1 is smaller than str2, return <0 (but not necessarily scheduled-1, many online say-1, it is incorrect, the specific value size depends on the actual situation ).
If str1 is greater than str2, return> 0 (but different timing 1, the specific value size depends on the actual situation ).
The instance code is as follows:
strcmp(date('Y-m-d',$user->last_time), date("Y-m-d",time())) == 0
If case insensitive
Strncasecmp is used to compare a part of a case-insensitive string. it starts from the beginning of the string and the third parameter is the length to be compared:
The instance code is as follows:
Echo strncasecmp ("abcdd", "abcde", 3); // returns 0, comparing abc and abc. The two are the same because they are case insensitive.
We can also use = to compare php strings, as shown in
The instance code is as follows:
$ A = 'a'; $ B = 'www .phprm.com '; if ($ a = $ B) {echo 'equal';} else {echo 'unequal ';}
You can also use = to compare
The instance code is as follows:
22 = "22"; // return true
Article address:
Reprint at will ^ please include the address of this article!