Jump to content

Archived

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

stickman

String equals 0??

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

Share this post


Link to post
Share on other sites
See this page:

http://www.php.net/manual/en/language.types.string.php#language.types.string.conversion

and this page:

http://www.php.net/manual/en/language.types.type-juggling.php

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.