strcasecmp
PHP function
Edit on GitHub ✎
(PHP 4, PHP 5, PHP 7, PHP 8)
Binary safe case-insensitive string comparison
Description
strcasecmp(string $string1, string $string2): int
Binary safe case-insensitive string comparison. The comparison is not locale aware; only ASCII letters are compared in a case-insensitive way.
Parameters
string1The first string
string2The second string
Return Values Return
Changelog
| Version | Description |
|---|
Examples
strcasecmp() example
php
<?php
$var1 = "Hello";
$var2 = "hello";
if (strcasecmp($var1, $var2) == 0) {
echo '$var1 is equal to $var2 in a case-insensitive string comparison';
}
?>