Page 1 of 1

A small question..

Posted: Fri Feb 21, 2003 2:15 pm
by invincible
Hi,

I am new to php, just started.. i was trying this:

$var1=3;

$var2 = 3.0;

if(var1==var2)
print "true";
else
print "false";



if (var1===var2)
print "true1";
else
print "false";


the tutorial says == just checks the equality, so doesnt that mean the first test should return a true ?? but the answer is false in both tests. Please explain.

Thanks

Posted: Fri Feb 21, 2003 3:00 pm
by decoy1
You forgot to precede the variables in the if statement with '$'. Change it and it will be true.

Code: Select all

if($var1==$var2)  <-- HERE 
  print "true"; 
else 
  print "false";

Thanks

Posted: Fri Feb 21, 2003 3:06 pm
by invincible
that was stupid of me. :oops:

Posted: Fri Feb 21, 2003 3:26 pm
by decoy1
Its not stupid, just part of learning. :)