Jump to content


Photo

String equals 0??


  • Please log in to reply
2 replies to this topic

#1 stickman

stickman
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 19 August 2006 - 02:35 AM

Lets say I have this code:

<?php
$var = "Text";

if($var==0) {
     echo "A string is equivalent to an integer";
} else {
     echo "A string is NOT equivalent to an integer";
}
?>

How come everytime I execute that, it outputs:

A string is equivalent to an integer

I mean, the string "Text" is not the same as the integer 0, so how are they equivalent? Is there something I'm doing wrong or did I miss reading somewhere that a string equals 0 when compared to an integer?

Thanks in advance for your help!!!

..:: FREE NINTENDO WII OR $250 CASH ::..
..:: Click here for more information ::..


#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 19 August 2006 - 02:39 AM

See this page:

http://www.php.net/m...ring.conversion

and this page:

http://www.php.net/m...pe-juggling.php

#3 stickman

stickman
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 19 August 2006 - 02:42 AM

Thank you. That answered my question.

..:: FREE NINTENDO WII OR $250 CASH ::..
..:: Click here for more information ::..





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users