String comparison function; comparison function; string comparison

php strcmp() function syntax

Function:Compare two strings (case sensitive)

Syntax:strcmp(string1,string2)

Parameters:

Parameters Description
string1 Required, specifies the first string to be compared.
string2 Required, specifies the second string to be compared.

Description:strcmp() function compares two strings. The strcmp() function is binary-safe and case-sensitive. If the two strings are equal, 0 is output. If string1 is less than string2, the output value is less than 0. If string1 is greater than string2, the output value is greater than 0.

php strcmp() function example


Run instance»

Click the "Run instance" button to view the online instance

Output:

1



Run Instance»

Click the "Run Instance" button to view the online instance

Output:

-1