PHP strcasecmp() Function

P
PHP str_word_count() Function
PHP strchr() 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 in php

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 use 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_word_count() Function
PHP strchr() Function

Add comment

Tutor Network

Share this

Learn PHP from A to Z