Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP strcasecmp() Function

PHP strcasecmp() Function

PHP String Reference Manual PHP String Reference Manual

Example

Compare two strings (case-insensitive):

Run Example »


Definition and Usage

The strcasecmp() function compares two strings.

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

**Tip:** The difference between this function and strncasecmp() The strcasecmp() function is similar, except that with strncasecmp() you can specify the number of characters of each string to compare.


Syntax

strcasecmp(

string1,string2

)

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

Technical Details

| Return value: | This function returns:

| | --- | --- | | PHP Version: | 4+ |

More examples

Example 1

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

"; echo strcasecmp("Hello","hELLo"); ?>

Run Example »

Example 2

Different return values:

Run Example »


PHP String Reference Manual PHP String Reference Manual