Bug #15201 Updated: ('foo'==0) => equal ?

From: Date: Thu, 24 Jan 2002 11:20:29 +0000
Subject: Bug #15201 Updated: ('foo'==0) => equal ?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-77983@lists.php.net to get a copy of this message
ID: 15201 Updated by: derick Old Summary: ('foo'==0) => equal ? Reported By: alberty@neptunelabs.de Old Status: Open Status: Bogus Bug Type: Variables related Operating System: i688-gnu-linux PHP Version: 4.0CVS-2002-01-24 New Comment: It's indeed due to automatic conversion. The vars get converted to ints, and the integer value of 'foo' = 0 Use if ($a === $b) to check for both value and type. Derick Previous Comments: ------------------------------------------------------------------------ [2002-01-24 06:15:26] alberty@neptunelabs.de A simple condition with a strange result: <?php $a='foo'; $b=0; if ($a==$b) echo 'equal'; else echo 'not equal'; ?> result: $a and $b is equal, but if $b unequal zero the condition results 'not equal' This is not really rationally. Is the problem the automatic type casting? Regards, Steve ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=15201&edit=1

« previous php.dev (#77983) next »