A small question..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
invincible
Forum Newbie
Posts: 4
Joined: Fri Feb 21, 2003 2:15 pm

A small question..

Post 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
decoy1
Forum Commoner
Posts: 50
Joined: Fri Feb 21, 2003 1:33 pm
Location: St. Louis

Post 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";
invincible
Forum Newbie
Posts: 4
Joined: Fri Feb 21, 2003 2:15 pm

Thanks

Post by invincible »

that was stupid of me. :oops:
decoy1
Forum Commoner
Posts: 50
Joined: Fri Feb 21, 2003 1:33 pm
Location: St. Louis

Post by decoy1 »

Its not stupid, just part of learning. :)
Post Reply