PHP Comparative Operators - PHP Operators - for php

PHP Comparative Operators

Best PHP Training with Live Project in Noida Fee is only 7500/-Click here for FREE DEMO.

/ins>

PHP comparative operators


PHP
lets you Compare one variable or value with another via its wide range of comparison operators.

Common Comparison Operators
OperatosDescription
==Equal to
===Equal to and of the same type
!=Not equal to
!==Not equal to and of the same type
>Greater than
<Less than
>=Greater than or equal to
<=Less than or equal to

Here’s example illustrating these operators in action

Eg ( == and === )

in the above example.
Two variable $x , $y define
$x hold the value 10
$y hold value 10.0

Now perform several operation on this
First check ($x==$y)=>it returns true because the value for both is same
Second Check($x===$y)=>it returns false because now it also compare data-type. $y hold a float value.


Difference between ( == and === )

$bool=(boolean)1
($bool==$int) it returns true because both have same value

$int= (integer)1
($bool===$int) its return false because both have different data type


Use of( >, <, >=, <= )

$a hold the value 10
$b hold the value 11

check ($a>$b)=> returns false because $a less than $b.
check($a>=$b)=> returns true because $a neighter grater nor equal to $b.

Keep Updating yourself