Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,855 questions

51,776 answers

573 users

How to use comparison operators in PHP

1 Answer

0 votes
$x = 100;
$y = 100;
if ($x == $y)  // true if $x is equal to $y     
    echo "x = y <br />";
    
$x = 100;
$y = 100.0;
if ($x === $y) // true if $x is equal to $y, and with the same type     
    echo "x === y <br />";
else
    echo "x not equal to y <br />";
    
$x = 100;
$y = 9;
if ($x != $y) // true if $x is not equal to $y     
    echo "x != y <br />";
if ($x <> $y) // true if $x is not equal to $y     
    echo "x <> y <br />";
    
$x = 100;
$y = 100.0;
if ($x !== $y) // true if $x is not equal to $y, or they are not with the same type 
    echo "x !== y <br />";    
    
$x = 100;
$y = 7;
if ($x > $y) // true if $x is greater than $y 
    echo "x > y <br />";
    
$x = 100;
$y = 180;
if ($x < $y) // true if $x is less than $y     
    echo "x < y <br />";
    
$x = 180;
$y = 180;
if ($x >= $y) // true if $x is greater than or equal to $y     
    echo "x >= y <br />";
if ($x <= $y) // true if $x is less than or equal to $y
    echo "x <= y <br />";



/*
run:

x = y 
x not equal to y 
x != y 
x <> y 
x !== y 
x > y 
x < y 
x >= y 
x <= y 

*/

 



answered Nov 5, 2015 by avibootz

Related questions

2 answers 195 views
2 answers 206 views
1 answer 156 views
1 answer 229 views
1 answer 167 views
167 views asked Apr 18, 2015 by avibootz
...