.


Divya

strcmp() function in php


The strcmp() function is used to compares two strings in PHP.

Example

<?php
$var1 = "Hello";
$var2 = "Hello";
echo strcmp($var1, $var2);
?>

If it returns 0, then two strings are equal.

<?php
$var1 = "Hello";
$var2 = "hello";
echo strcmp($var1, $var2);
?>

If it returns -1, then two strings are not equal.

<?php
$var1 = "hello";
$var2 = "Hello";
echo strcmp($var1, $var2);
?>

If it returns 1, then two strings are not equal.



.