Home > Backend Development > PHP Tutorial > php strcasecmp and strncasecmp functions

php strcasecmp and strncasecmp functions

WBOY
Release: 2016-07-29 09:15:30
Original
1657 people have browsed it

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
    If two strings are equal
less than 0
    if string1 is less than string2
is greater than 0
    if string1 is greater than string2
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
    If two strings are equal
less than 0
    if string1 is less than string2
is greater than 0
    if string1 is greater than string2
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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template