PHP Programing language

Comparison or Relational Operator Examples
Previous Home Next

In PHP using the Comparison or Relational Operator :

OPERATOROPERATION
= = Equal
= = = Identical
!= Not equal
<> Not equal
!= = Not identical
< Less than
> Greater than
< = Less than or Equal to
>= Greater than or Equal to

 

Example for Comparison Operator

<html>
<head>
<title>Using Comparison Operator</title>
</head>
<body>
<h1>The example for using comparison operator</h1>
	<?php
	$s = 10;
	$a = 5;
	$y = "200 pack";
	$i = "hello";
	$o = "php";
	printf ("$s == $a :%d <br>", $s==$a);
	printf ("$s != $a :%d <br>", $s!=$a);
	printf ("$s <> $a :%d <br>", $s<>$a);
	printf ("$s === $y :%d <br>", $s===$y);
	printf ("$s !== $y :%d <br>", $s!==$y);
	printf ("$s > $a :%d <br>", $s > $a);
	printf ("$i > $o :%d <br>", $i > $o);
	printf ("$s < $a :%d <br>", $s < $a);
	printf ("$i < $o :%d <br>", $i < $o);
	printf ("$s >= $a :%d <br>", $s >= $a);
	printf ("$i >= $o :%d <br>", $i >= $o);
	printf ("$s <= $a :%d <br>", $s <= $a);
	printf ("$i <= $o :%d <br>", $i <= $o);
	?>
	</body>
	</html>
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: