Bug #12453 Updated: comparing 0==null is true?

From: Date: Tue, 31 Jul 2001 12:40:36 +0000
Subject: Bug #12453 Updated: comparing 0==null is true?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-61627@lists.php.net to get a copy of this message
ID: 12453
Updated by: andy
Reported By: btanner@home.com
Old Summary: comparing 0=="null" is true?
Status: Open
Bug Type: Scripting Engine problem
Operating System: Win2k
PHP Version: 4.0.6
New Comment:

i thought that any integer =0 was also equal to any string...

for example (in your script):

$MyVar=0;
if ($MyVar=="blahblahblahblah")
echo "yes";
else
echo "no";


will echo "yes"

I don't know if this is supposed to happen, but it does.
If you set the $MyVar=1, the script prints no.

Can anybody else verify if this is supposed to happen, or
if this is actually a bug?


Previous Comments:
------------------------------------------------------------------------

[2001-07-28 22:54:40] btanner@home.com

If you compare the integer(0) to the string "null", PHP thinks they are the same.

Am I hopped up on goofballs, or whats up here?

$MyVar=0;
if($MyVar=="null")
	print("apparently $MyVar is equal to \"null\"");
else
	print("its not null, its $MyValue");



------------------------------------------------------------------------



Edit this bug report at http://bugs.php.net/?id=12453&edit=1



Thread (6 messages)

« previous php.dev (#61627) next »