Home > Article > Backend Development > Introduction to PHP strcmp() function_PHP tutorial
The strcmp() function compares two strings.
strcmp syntax:
strcmp(string1,string2)
Parameter Description
string1 Required. Specifies the first string to compare.
string2 Required. Specifies the second string to be compared.
This function returns:
If the two strings are equal<0 - if string1 is less than string2 >0 - if string1 is greater than string2
Example: Use strcmp to determine whether it belongs to a certain One day (based on 00:00)
strcmp(date(Y-m-d,$user->last_time), date("Y-m-d",time())) == 0