Re: = 0 and = "0"

From: Date: Mon, 25 Jun 2001 08:31:46 +0000
Subject: Re: = 0 and = "0"
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-72209@lists.php.net to get a copy of this message
Hello Robin, Very simple. :) RC> <? $qty = "0" ; if ($qty != "test") print "qty is not test"; RC> ?> $qty is string, so PHP compares "0" with "test" char by char. chr("0") isn't equal "t". RC> <? $qty = 0 ; if ($qty != "test") print "qty is not test"; ?> In this case $qty is integer value, so PHP tries to convert "test" to integer value [ integer("test") == 0], so last condition result is FALSE. Is it clear? RC> Thanks, RC> Robin -- Best regards, Vitali Falileev mailto:falileev@itos.eu.org

« previous php.general (#72209) next »