• PHP Video Tutorials

PHP - Function Strcmp



Syntax

strcmp(string1,string2)

Definition and Usage

It is used to compare two strings

Return Values

It returns the string functions

Parameters

Sr.No Parameters & Description
1

string1

It specifies the first string to compare

2

string2

It specifies the second string to compare

Example

Try out the following example

<?php
   echo "If this function returns 0, the two strings are equal.";
   echo "<br> The result is ";
   echo strcmp("Hello world!","Hello world!");
?>

This will produce following result −

If this function returns 0, the two strings are equal.
The result is 0
php_function_reference.htm
Advertisements