Jump to content


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


String equals 0??

Recommended Posts

Lets say I have this code:

$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!!!

Share this post

Link to post
Share on other sites
See this page:


and this page:


Share this post

Link to post
Share on other sites


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.