Bug #12876: Comparison with zero (0) returns TRUE

From: Date: Tue, 21 Aug 2001 14:27:54 +0000
Subject: Bug #12876: Comparison with zero (0) returns TRUE
Groups: php.dev 
Request: Send a blank email to php-dev+get-63971@lists.php.net to get a copy of this message
From:             ash@freaky-namuh.com
Operating system: Linux Debian 2.2r2 (testing)
PHP version:      4.0.6
PHP Bug Type:     Strings related
Bug description:  Comparison with zero (0) returns TRUE

When strings are compared to 0, they always return TRUE.

<?php
$test = 'somestring';
if( $test == 'somestring')
echo "Match 1\n";
if( $test == 0 )
echo "Match 2\n";
if( $test == 1 )
echo "Match 3\n";
if( $test != 0 )
echo "Match 4\n";
if( $test != 'somestring' )
echo "Match 5\n";
if( $test != 1 )
echo "Match 6\n";
?>

Expected Output:
Match 1


Actual Ouput:
Match 1
Match 2
Match 6

Is there something I'm missing?

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



Thread (4 messages)

« previous php.dev (#63971) next »