Home>Article>Backend Development> How to use php strncasecmp function?

How to use php strncasecmp function?

藏色散人
藏色散人 Original
2019-05-30 11:14:41 2455browse

php The strncasecmp function is used to compare two strings. Its syntax is strncasecmp(string1,string2,length). The parameter string1 is required and refers to the first string to be compared; string2 is required and specifies the second string to be compared. string.

How to use php strncasecmp function?

php How to use strncasecmp function?

Definition and usage

strncasecmp() function compares two strings.

Note: strncasecmp() is binary safe and case-insensitive.

Tips: This function is similar to the strcasecmp() function, except that strcasecmp() has no length parameter.

Syntax

strncasecmp(string1,string2,length)

Parameters

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:

This function returns:

0 - if the two strings are equal

a8bacc06128749489fc86bda2552a2bc0 - if string1 is greater than string2

PHP version: 4

Example 1

Compare two String (not case sensitive, China and CHINA output are the same):

"; echo strncasecmp("China","CHINA",6); ?>

Output:

0 0

Example 2

Compare two strings (not case sensitive):

Output:

0

The above is the detailed content of How to use php strncasecmp function?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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