Easy Tutorial
❮ Php Exception Func Misc Pack ❯

PHP strcasecmp() Function

PHP String Reference Manual

Example

Compare two strings (case-insensitive):


Definition and Usage

The strcasecmp() function compares two strings.

Note: The strcasecmp() function is binary-safe and case-insensitive.

Note: This function is similar to the strncasecmp() function, except that with strncasecmp(), you can specify the number of characters to compare for each string.


Syntax

Parameter Description
string1 Required. Specifies the first string to compare.
string2 Required. Specifies the second string to compare.

Technical Details

Return Value: The function returns: 0 - if the two strings are equal<br> <0 - if string1 is less than string2<br> >0 - if string1 is greater than string2
PHP Version: 4+
--- ---

More Examples

Example 1

Compare two strings (case-insensitive, HELLO and hELLo output the same):

Example 2

Different return values:

❮ Php Exception Func Misc Pack ❯