Search This Blog

comparison operators in php

                                           comparison operators :   == , <= , >= , != , < , > 



<?php
$num1=10;
$num2='10';


if($num1==$num2)
echo "$num1 is equal to $num2";


?>
output : 


nothing to display , $num1 is integer and  $num2 is string , string is not equal to integer


<?php
$num1=10;
$num2=20;


if($num1==$num2)
echo "$num1 is equal to $num2";


?>
output : 


nothing to display , because both are not equal





<?php

$num1=10;
$num2=20;


if($num1<=$num2)
echo "$num1 is less than or equal to $num2";


?>
output : 10 is less than or equal to 20



<?php
$num1=10;
$num2=20;


if($num1>=$num2)
echo "$num1 is grater than or equal to $num2";


?>

output : 


nothing to display , because 10  is not grater than or equal to 20






<?php

$num1=10;
$num2=20;


if($num1!=$num2)
echo "$num1 is not equal to $num2";


?>
output : 10 is not equal to 20



<?php
$num1=10;
$num2=20;


if($num1<$num2)
echo "$num1 is less than to $num2";


?>
output : 10 is less than to 20





<?php

$num1=10;
$num2=20;


if($num1>$num2)
echo "$num1 is grater than $num2";


?>
output :
nothing to display , because10  is not grater than to 20
















Share Links

Related Posts Plugin for WordPress, Blogger...