Output Here is the output - 32 example Let's see another example - Now"/> Output Here is the output - 32 example Let's see another example - Now">

Home  >  Article  >  Backend Development  >  strcmp() function in PHP

strcmp() function in PHP

WBOY
WBOYforward
2023-08-31 09:09:081270browse

strcmp() function in PHP

strcmp() function is used to compare two strings.

Note - This function is case sensitive.

Syntax

strcmp(str1, str2)

Parameters

  • str1 - The first string to compare

  • str2 - The second string to compare

Returns

The strcmp() function returns -

  • 0 - if the two strings are equal

  • >0 - If string1 is greater than string2

Example

The following is an example-

Live demonstration

<?php
   echo strcmp("windows","Windows");
?>

Output

The following is the output -

32

Example

Let’s see another example-

Live Demonstration

<?php
   echo strcmp("Windows OS","Windows Operating System");
?>

Output

Here is the output-

-7424

The above is the detailed content of strcmp() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete