php8.5
Home/ Manual/ strings / functions/ strcasecmp

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

string1

The first string

string2

The second string

Return Values Return

Changelog

VersionDescription

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';
}
?>

See Also

Source: reference/strings/functions/strcasecmp.xml · from the official PHP manual (php/doc-en)