PHP strcasecmp() Function

PHP str_replace() Function
PHP STR_ROT13() FUNCTION

WHAT IS THE SYNTAX OF THE STRCASECMP() FUNCTION IN PHP?

strcasecmp(string1,string2)
ParameterDescription
string1Required. Specifies the first string to compare
string2Required. Specifies the second string to compare
PHP STRCASECMP() method

EXAMPLES OF THE STRCASECMP() FUNCTION

Example 1. In this example, we compare two strings (case-insensitive).

<?php
echo strcasecmp("Hello world!","HELLO WORLD!");
?>

Example 2. In this example, we compare two strings (case-insensitive = HELLO and hELLo will output the same).

<?php
echo strcasecmp("Hello","HELLO");
echo "<br>";
echo strcasecmp("Hello","hELLo");
?>

Example 3. In this example, we different return values.

<?php
echo strcasecmp("Hello world!","HELLO WORLD!"); // The two strings are equal
echo strcasecmp("Hello world!","HELLO"); // String1 is greater than string2
echo strcasecmp("Hello world!","HELLO WORLD! HELLO!"); // String1 is less than string2
?>
PHP str_replace() Function
PHP STR_ROT13() FUNCTION
en English
X
Scroll to Top