Home >Backend Development >PHP Tutorial >php strcasecmp and strncasecmp functions
strcasecmp() function
Definition: strcasecmp() function compares two strings.
Syntax: strcasecmp(string1,string2);
Parameter list
Parameter | Description |
---|---|
string1 | Required. Specifies the first string to compare. |
string2 | Required. Specifies the second string to be compared. |
Return value:
Return value: | The function returns: |
---|---|
is equal to 0 |
|
less than 0 |
|
is greater than 0 |
|
PHP version | 4+ |
strncasecmp() function
Definition: strcasecmp() function compares two strings.
Syntax: strncasecmp(string1,string2,length);
Parameter list
Parameter | Description |
---|---|
string1 | Required. Specifies the first string to compare. |
string2 | Required. Specifies the second string to be compared. |
length | Required. Specifies the number of characters per string used for comparison. |
Return value:
Return value: | The function returns: |
---|---|
is equal to 0 |
|
less than 0 |
|
is greater than 0 |
|
PHP version | 4+ |
Note: The difference between the strcasecmp() function and the strncasecmp() function is that strncasecmp() has an additional specified length of comparison characters in the parameter.
Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above has introduced the php strcasecmp and strncasecmp functions, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.