Home >Backend Development >PHP Tutorial >Is substr_compare() case sensitive in php?

Is substr_compare() case sensitive in php?

(*-*)浩
(*-*)浩Original
2019-09-05 15:18:272135browse

PHP substr_compare() function

Is substr_compare() case sensitive in php?

##Definition and usage

substr_compare() function compares two strings from the specified starting position.

Tip: This function is binary safe and optionally case sensitive (case sensitive).

Grammar (Recommended learning: PHP video tutorial)

substr_compare(string1,string2,startpos,length,case)

Parameter description:

string1 , required. Specifies the first string to compare.

string2 , required. Specifies the second string to be compared.

startpos, required. Specifies where in string1 to start comparison. If negative, counting starts from the end of the string.

length, optional. Specifies how many characters in string1 are compared (number of characters).

case, optional.

Boolean value specifying whether to perform case-sensitive comparisons:

FALSE - Default. Case sensitive

TRUE - Not case sensitive

This function returns:

0 - If the two strings are equal

e63aabeb0339d3bb08f16fffcf1b80a20 - if string1 (startpos) is greater than string2

if length is greater than or equal to string1 length, the function returns FALSE.

Example:

<?php
echo substr_compare("Hello world","Hello world",0);
?>

The above is the detailed content of Is substr_compare() case sensitive in php?. 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