Ahh.. the trick question. hah..  Ok, let me see if I remember this (although it 
doesn't seem to follow the logic in my head.. I know someone else will explain 
it better but let me take a crack at it):

When comparing a two different variable types that PHP thinks it knows how to 
compare, it will try.  In this case, I believe the 'A' gets converted to a 
true/false type thing (0 or 1).. although I thought it'd convert to a 1 so 
you'd have if (1 == 0) which would be false.

At any rate, something like that is happening and it's comparing values that 
you don't think you're comparing.

Try using the triple equal sign operator (===) instead of the dobule (==).  
This forces PHP to not do the conversion.. to compare EXACT values.  Using === 
means that 0 does not equal '0' because 0 is an int and '0' is a string.

Someone else will give a better explaination soon, just wanted to give you 
something so you weren't stuck/frustrated/etc for too long.

-TG

= = = Original message = = =

Could anyone tell me why this code echos?
 
<?php
 $value = 0;
 $curval = 'A';
 if ($value == $curval) 
  echo "WTH, Over<br>";
 
?>


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to