PHP strcmp() Function

PHP strchr() Function
PHP strcoll() Function

what is the syntax of the STRCMP() function in php?

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

examples of the STRCMP() function in php

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

<?php
echo strcmp("Hello world!","Hello world!");
?>

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

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

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

<?php
echo strcmp("Hello world!","Hello world!"); // the two strings are equal
echo strcmp("Hello world!","Hello"); // string1 is greater than string2
echo strcmp("Hello world!","Hello world! Hello!"); // string1 is less than string2
?>
PHP strchr() Function
PHP strcoll() Function
en English
X
Scroll to Top