Home >Backend Development >PHP Tutorial >How to use php strncasecmp function

How to use php strncasecmp function

藏色散人
藏色散人Original
2019-01-31 11:01:343105browse

PHP The strncasecmp function represents a binary safe comparison of several characters at the beginning of a string (not case-sensitive). Its syntax is strncasecmp(string1, string2, length). The parameter string1 is required and specifies the first string to be compared. ;string2 is required, it is the second string to be compared...

How to use php strncasecmp function

php How to use strncasecmp function?

Function: Compare the first n characters of the string, case-insensitive

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.

Description: The strncasecmp() function compares two strings. strncasecmp() is binary-safe and case-insensitive. If the two strings are equal, 0 is output. If string1 is greater than string2, the output value is greater than 0. If string1 is less than string2, the output value is less than 0.

php strncasecmp() function example

<?php
echo strncasecmp("Hello","hello",6);
?>

Output:

0

This article is an introduction to the PHP strncasecmp function. I hope it will be helpful to friends who need it. Helps!

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

Related articles

See more