Jump to content

String equals 0??


stickman

Recommended Posts

Lets say I have this code:

[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";
}
?>
[/code]

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!!!
Link to comment
https://forums.phpfreaks.com/topic/18007-string-equals-0/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.