Is substr_compare() case sensitive in php?

(*-*)浩
Release: 2023-04-07 11:42:01
Original
2107 people have browsed it

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)
Copy after login

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

<0 - if string1 (startpos) is less than string2

>0 - 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);
?>
Copy after login

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!

Related labels:
php
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