Home > Article > Backend Development > How to use php strcasecmp function
PHP strcasecmp function is used for binary safe comparison of strings (case insensitive). The syntax is strcasecmp(string1,string2). The parameter string1 must specify the first string to be compared, and string2 must specify the second string to compare.
php How to use strcasecmp function?
Function: Compare two strings (not case sensitive)
Syntax:
strcasecmp(string1,string2)
Parameters:
string1 Required, specify The first string to compare.
string2 Required, specifies the second string to be compared.
Note: The strcasecmp() function is binary safe and case-insensitive.
php strcasecmp() function usage example:
<?php echo strcasecmp("hello world","HELLO WORLD")."<br>"; echo strcasecmp("hello world","HELLO php")."<br>"; echo strcasecmp("hello world","HELLO php.cn"); ?>
Output:
0 7 7
This article is an introduction to the PHP strcasecmp function. Hope it helps those in need!
The above is the detailed content of How to use php strcasecmp function. For more information, please follow other related articles on the PHP Chinese website!